5 steps to optimizing wcf services

10
5-steps to Optimizing WCF services Punit Ganshani

Upload: punit-ganshani

Post on 27-Jun-2015

2.639 views

Category:

Technology


1 download

DESCRIPTION

Presentation by Punit Ganshani on 5 quick steps to Optimizing your WCF services

TRANSCRIPT

Page 1: 5 steps to Optimizing WCF Services

5-steps to Optimizing WCF servicesPunit Ganshani

Page 2: 5 steps to Optimizing WCF Services

Punit GanshaniPunit Ganshani is a Technology Evangelist practising application design & development on C#, WCF, WP8, WinRT and Open Source. He is an open-source contributor on CodePlex, has several applications on Windows Phone Store, author of a book, and 18+ whitepapers in international magazines.

Twitter - @ganshani@codetails

LinkedIn -Connect

SlideShare –View Presentations

Blog Sites – www.ganshani.com www.codetails.comOpen Source –CodeInject, Workflow Extractor, dI.Hook

Page 3: 5 steps to Optimizing WCF Services

Choose the right binding

Source: http://weblogs.asp.net/blogs/spano/WCFBindings.JPG

Step 1

Page 4: 5 steps to Optimizing WCF Services

Choosing the Encoder

Default encoderText• BasicHttpBinding and WsHttpBinding• Uses XML UTF-8 encoding

Interoperable formatMTOM• More optimized transmission of binary blobs• Not base-64 encoded, hence faster

Default encoder w/binary formatBinary

• NetTcpBinding and NetNamedPipeBinding• Avoids base64 encoding and use Session Encoders• Uses a dictionary-based algorithm to avoid data

duplication

Step 2

Page 5: 5 steps to Optimizing WCF Services

Which Encoder?

▪ Supports the right binding

▪ Size of the message▪ Choose one that shortens your message▪ Smaller the size of message, faster it will be transferred

▪ Check the CPU load▪ Encoding takes time and CPU cycles

▪ Keep it Simple Stupid (KISS)▪ Remove redundant attributes / properties from message▪ Keep it binary if possible

▪ Interoperable▪ MTOM – check for interoperability with non-WCF services

Step 2

Page 6: 5 steps to Optimizing WCF Services

Session Encoders.. Build / reuse

▪ Binary encoder has Session Encoders▪ Builds a dictionary based on pattern of

messages▪ Uses dictionary and analysis pattern for

encoding▪ Optimizes speed as time goes by

▪ Other encoders▪ Build your own session encoder

Step 2

Page 7: 5 steps to Optimizing WCF Services

Compress after encoding

▪ A right encoder reduces message size by 4-5 times

▪ But the shorter the message, the better▪ WAS/IIS Hosted Service: Use IIS compression ▪ Others: Uses GZip and Deflate mechanisms

for all outgoing/incoming messages

▪ For custom compression, hook the encoder and apply compression techniques

Step 3

Page 8: 5 steps to Optimizing WCF Services

Cache

▪ Register your dependencies, and locate them when required

▪ Consider caching data,▪ In memory Cache -

▪ Ideal for small sized application hosted on a single instance/server

▪ WAS/IIS Hosted Services: Use ASP.NET Caching Services or Runtime Caching

▪ Self hosted: Use Enterprise Library

▪ App-Fabric:▪ Ideal for distributed hosted applications▪ Overcomes several problems such as sticky

sessions, component-dependent caching, dirty cache and cache-synchronizing

Step 4

Page 9: 5 steps to Optimizing WCF Services

Small things, big difference

▪ Load Balance:▪ Increases scalability▪ Increases performance

▪ Use GPU for data computing:▪ Accelerator by Microsoft▪ CUDA by NVIDIA

Step 5

Page 10: 5 steps to Optimizing WCF Services