DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Data Engineering
  3. Data
  4. WCF over HTTPS, Compression, and Binary Binding

WCF over HTTPS, Compression, and Binary Binding

Ricci Gian Maria user avatar by
Ricci Gian Maria
·
Sep. 16, 12 · Interview
Like (0)
Save
Tweet
Share
14.68K Views

Join the DZone community and get the full member experience.

Join For Free

i have an application that is composed by wpf clients deployed over the internet and a central wcf service exposed over https for security reasons . everything works fine, but as the number of clients grows, performance starts to decrease a little. since i have a great number of clients that operates behind a single standard adsl 8 mbit (used for everything, mail, browsing, etc..), i measured and found that bandwidth is becoming a bottleneck, so i need to reduce the amount of traffic between clients and server .

it turns out that the easiest way to gain bandwidth is enabling iis dynamic compression , as you can read on this interesting article by scott hanselman that explains in great details how you can enable compression in iis. since my server has plenty of cpu available, compression is a really interesting way to reduce bandwidth.

this is not the only option -- you can also enable binary serialization over http because binary serialization usually is smaller than standard serialization you obtain with datacontractserializer . the only drawback is that such an endpoint is accessible only with wcf client; but if this is an issue it is really simple to expose the same service with multiple endpoints, each one with a different binding. i decided to add another endpoint with custombinding to use the binarymessageencoding (because i want to be interoperable with non .net clients), so i added this binding configuration

<custombinding>
  <binding name="binaryhttpbindingwithnoauth">
    <binarymessageencoding>
      <readerquotas maxdepth="32" maxstringcontentlength="2100000000" maxarraylength="16384" maxbytesperread="2147483647" maxnametablecharcount="16384" />
    </binarymessageencoding>
    <httpstransport />
  </binding>
 
  <binding name="binaryhttpbinding">
    <binarymessageencoding>
      <readerquotas maxdepth="32" maxstringcontentlength="2100000000" maxarraylength="16384" maxbytesperread="2147483647" maxnametablecharcount="16384" />
    </binarymessageencoding>
    <security authenticationmode="usernameovertransport">
 
    </security>
    <httpstransport />
  </binding>
</custombinding>

then i added another endpoint of this service that use this binding (actually i have more than a single wcf service, some of them without authentication, some other that needs to be authenticated, this is the reason why i need two configuration for binding).

then i modified my client program to be able to use standard or binary endpoint with a user settings and i started to measure bandwidth usage in various situation. i’ve started with a real scenario, startup of the application with production real data , because during startup the application issues seventeen requests to the service to initialize everything, it start requesting customer information, then try to login the user and finally loads all data the user needs to start working. i can improve performances reducing number of requests, but actually i’m interested only in download bandwidth.

here is the sum of bytes downloaded for all the requests, first column is soap uncompressed, second one soap compressed, third column binarymessageencoding uncompressed, and finally fourth column binarymessageencoding compressed.

image

figure 1: measurement over the amount of data downloaded at application startup

with soap binding and no compression the startup download ~262kb of data and since data is mostly textual, simply enabling http dynamic compression (second column) saved ~80% of the bandwidth , because total amount of data is now ~52kb. now it is interesting to compare these numbers with binarymessageencoding (third column) because the total size is ~155kb, a ~40% saving respect soap uncompressed data . this is interesting because if for some reason you have small cpu power to enable compression, with binary encoding you can still save a lot of bandwidth without resorting to compression. the fourth column represents binaryencoding with dynamic compression, since the content is mostly textual i can gain ~76% of the bandwidth (36kb instead of 155kb) enabling compression even for the binary encoding . it is a ~30% save respect to compressed soap and ~86% gain respect to soap uncompressed.

these numbers can vary a lot in your situation, because they are highly dependent on the format of the data (i need to send large portion of textual data so my data is highly compressible), but it takes some measurement to understand if you can gain a similar amount of bandwidth with your data. the important stuff is that everything is done simply by changing wcf configuration, and you do not need to change a single line of code.

Windows Communication Foundation HTTPS Binding (linguistics) Data (computing) Bandwidth (computing)

Published at DZone with permission of Ricci Gian Maria, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • ChatGPT: The Unexpected API Test Automation Help
  • Image Classification With DCNNs
  • Last Chance To Take the DZone 2023 DevOps Survey and Win $250! [Closes on 1/25 at 8 AM]
  • A Simple Union Between .NET Core and Python

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: