Do you know when to use the different WCF Context Modes?


Let's talk about WCF's InstanceContextMode, give a brief overview of the possible values and determine when to use them.

InstanceContextMode is a property on the ServiceBehaviorAttribute class in .NET Framework 4.5. A developer will use the InstanceContextMode property to specify when new service objects are created.

Because the service object is not directly connected to the communicating channel, the lifetime of the service objects is independent of the lifetime of the channel between a client and the service application. The default value, PerSession, instructs the service application to create a new service object when a new communication session is established between a client and the service application. Subsequent calls in the same session are handled by the same object.

There are 3 context modes in WCF:

  1. PerCall
  2. PerSession (Default)
  3. Single

The default value, PerSession, instructs the service application to create a new service object when a new communication session is established between a client and the service application. Subsequent calls in the same session are handled by the same object. PerSession indicates that each service object handles requests from one client channel. A service configured for private sessions cannot typically support more than a few dozen (or perhaps up to a few hundred) outstanding clients due to the cost associated with each such dedicated service instance.

PerCall creates a new InstanceContext object prior to and recycled subsequent to each call. If the channel does not create a session this value behaves as if it were PerCall. After the method call returns, if the object implements IDisposable, then Windows Communication Foundation calls IDisposable.Dispose on it.

Single creates only one InstanceContext object. It is used for all incoming calls and is not recycled subsequent to the calls. If a service object does not exist, one is created. The singleton service is the ultimate shareable service. When a service is configured as a singleton, all clients get connected to the same single well-known instance independently of each other, regardless of which endpoint of the service they connect to. The singleton service lives forever, and is only disposed of once the host shuts down. The singleton is created exactly once when the host is created.

Which instance context mode to use and when

Per session (Default)

• When you want to maintain states between WCF calls.
• When you don't have very many concurrent connections and don't need to scale up.
• When you have light resource references

Per call

• When you want a stateless services
• When your service holds intensive resources like connection and huge memory objects.
• When scalability is a prime requirement.
• When your WCF functions are called in a single threaded model.

Single

• When you want share global data through your WCF service.
• When scalability is not a concern.



90 comments:

  1. Nice Information
    Get Exclusive Telugu Movie News Online Easily at Pdtvindia.com, You can also read, Latest Telugu Cinema News [url= Telugu Movie News ][/url]

    ReplyDelete
  2. Buy Steroids Online 100% Legal! SDI Labs legal steroids alternative to HGH, Testosterone, Deca Durabolin, Winstrol, Anabolics, Dianabol for bodybuilding.
    best legal steroids

    ReplyDelete
  3. Male Extra Review is considered to have a totally natural formula especially for individuals who are facing the problem of the hair treatment, genetic hair loss.

    ReplyDelete
  4. male enhancement pills that work Does VigRX plus really work? Real reviews from customers, ingredients, side effects, clinical studies and where to buy.

    ReplyDelete
  5. test bank are written by leading nursing educators to reflect the latest standards and technology in the field of nursing.

    ReplyDelete
  6. The knowledge of technology you have been sharing thorough this post is very much helpful to develop new idea. here by i also want to share this.

    Data Science Training in Chennai
    Data science training in bangalore
    Data science online training
    Data science training in pune
    Data science training in kalyan nagar

    ReplyDelete
  7. I found your blog while searching for the updates, I am happy to be here. Very useful content and also easily understandable providing.. Believe me I did wrote an post about tutorials for beginners with reference of your blog. 
    Devops training in Chennai
    Devops training in Bangalore
    Devops Online training
    Devops training in Pune

    ReplyDelete
  8. headquartersnumbers All Headquarters Info - Find Corporate Office Addresses, Customer Service Phone Numbers, Company Email contacts, Social Media Pages & Complaint info.

    ReplyDelete
  9. Thank you for benefiting from time to focus on this kind of, I feel firmly about it and also really like comprehending far more with this particular subject matter. In case doable, when you get know-how, is it possible to thoughts modernizing your site together with far more details? It’s extremely useful to me.


    java training in annanagar | java training in chennai

    java training in marathahalli | java training in btm layout

    java training in rajaji nagar | java training in jayanagar

    java training in chennai

    ReplyDelete
  10. Hersolution Gel will ultimately lubricate your vagina, thus increasing the sensations and your desire for sexual pleasure. HerSolution was exclusively created

    ReplyDelete
  11. Useful Information :

    Looking for the Best [url= Digital Marketing Institute in Vijayawada ][/url] , We provide training on live projects, internship, Flexible Classes, Free Demo @ digitalinnovation.co.in

    ReplyDelete
  12. Useful Information :

    Looking for the Best [url= Digital Marketing Institute in Vijayawada ][/url] , We provide training on live projects, internship, Flexible Classes, Free Demo @ digitalinnovation.co.in

    ReplyDelete
  13. Maxoderm Reviews is the revolutionary topical Male Enhancement System discovered by thousands to help improve erection quality, sensation and the feeling of firmness.

    ReplyDelete
  14. Varelotteriet Hvert år spilles der i Varelotteriet om over 133 millioner kroner. Bare hovedgevinsten er på 3 millioner kroner. Med 205.000 lodsedler og 166.000+ gevinster hvert kvartal er Varelotteriet et af de lotterier i Danmark med de største chancer for at vinde.

    ReplyDelete
  15. Phen24 reviewst's been 90 days since I started using Phen24 to try and lose weight. Here's my Phen24review and results with and how I did it..

    ReplyDelete

  16. Hello! This is my first visit to your blog! We are a team of volunteers and starting a new initiative in a community in the same niche. Your blog provided us useful information to work on. You have done an outstanding job.

    AWS Online Training | Online AWS Certification Course - Gangboard
    AWS Training in Chennai | AWS Training Institute in Chennai Velachery, Tambaram, OMR
    AWS Training in Bangalore |Best AWS Training Institute in BTM ,Marathahalli

    ReplyDelete
  17. Very nice post here and thanks for it .I always like and such a super contents of these post.Excellent and very cool idea and great content of different kinds of the valuable information's.
    python online training
    python training in OMR
    python training course in chennai

    ReplyDelete
  18. Great content thanks for sharing this informative blog which provided me technical information keep posting.
    Online DevOps Certification Course - Gangboard
    Best Devops Training institute in Chennai

    ReplyDelete
  19. Great Article… I love to read your articles because your writing style is too good, its is very very helpful for all of us. Do check Six Sigma Training in Bangalore | Six Sigma Training in Dubai & Get trained by an expert who will enrich you with the latest trends.

    ReplyDelete
  20. phenq reviewsWow I can say that this is another great article as expected of this blog.Bookmarked this site.

    ReplyDelete
  21. Great Article… I love to read your articles because your writing style is too good, its is very very helpful for all of us. Do check Six Sigma Training in Bangalore | Six Sigma Training in Dubai & Get trained by an expert who will enrich you with the latest trends.

    ReplyDelete
  22. phentermine adipex Wow I can say that this is another great article as expected of this blog.Bookmarked this site.

    ReplyDelete
  23. A really good post,Its really very informative and interesting.it answers multiple questions that I had.Thanks a lot for sharing valuable information with us.
    aws online training

    ReplyDelete
  24. DO NOT BUY Provacyl Until You Read This Review! Check Out Side Effects, User Feedback and genuine Comments! Tips Included.
    phenq

    ReplyDelete
  25. A very nice guide. I will definitely follow these tips. Thank you for sharing such detailed article. I am learning a lot from you.

    rpa training in electronic-city | rpa training in btm | rpa training in marathahalli | rpa training in pune

    ReplyDelete
  26. winstrol germany Wow I can say that this is another great article as expected of this blog.Bookmarked this site.

    ReplyDelete
  27. 4vigrxoil Wow I can say that this is another great article as expected of this blog.Bookmarked this site.

    ReplyDelete
  28. I always enjoy reading quality articles by an individual who is obviously knowledgeable on their chosen subject. Ill be watching this post with much interest. Keep up the great work, I will be back
    Data Science training in Chennai | Data science training in bangalore

    Data science training in pune | Data science online training

    Data Science Interview questions and answers

    ReplyDelete
  29. Resources like the one you mentioned here will be very useful to me ! I will post a link to this page on my blog. I am sure my visitors will find that very useful
    Java training in Chennai | Java training in Bangalore

    Java online training | Java training in Pune

    ReplyDelete
  30. boosttestosterone2017 Wow I can say that this is another great article as expected of this blog.Bookmarked this site.

    ReplyDelete
  31. The knowledge of technology you have been sharing thorough this post is very much helpful to develop new idea. here by i also want to share this.
    Online DevOps Certification Course - Gangboard | Java online training

    ReplyDelete
  32. Great post! I am actually getting ready to across this information, It’s very helpful for this blog.Also great with all of the valuable information you have Keep up the good work you are doing well.
    Data Science Training in Indira nagar
    Data Science training in marathahalli
    Data Science Interview questions and answers

    ReplyDelete
  33. Computer Science Dissertation Writing Services https://www.wordsdoctorate.com/projects/computer-science-dissertation-writing-services/

    Chemistry Dissertation Writing Services https://www.wordsdoctorate.com/projects/chemistry-dissertation-writing-services/

    Social science Dissertation Writing Services https://www.wordsdoctorate.com/projects/social-science-dissertation-writing-services/

    Biotechnology Dissertation Writing Services https://www.wordsdoctorate.com/projects/biotech-dissertation-writing-services/

    Economics Dissertation Writing Services https://www.wordsdoctorate.com/projects/economics-dissertation-writing-services/

    Civil Engineering Dissertation Writing Services https://www.wordsdoctorate.com/projects/civil-engineering-dissertation-writing-services/

    Finance Dissertation Writing Services https://www.wordsdoctorate.com/projects/finance-dissertation-writing-services/

    ReplyDelete
  34. herrforcongress Wow I can say that this is another great article as expected of this blog.Bookmarked this site.

    ReplyDelete
  35. PhenQ is a prescription-free, natural alternative to weight loss drug phentermine. Now that you have an idea for how diet pills work, let's look at your best options.

    ReplyDelete
  36. PhenQ is a prescription-free, natural alternative to weight loss drug phentermine. Now that you have an idea for how diet pills work, let's look at your best options.

    ReplyDelete
  37. PhenQ Reviews is a prescription-free, natural alternative to weight loss drug phentermine. Now that you have an idea for how diet pills work, let's look at your best options.

    ReplyDelete
  38. This is most informative and also this post most user friendly and super navigation to all posts... Thank you so much for giving this information to me.. 
    angularjs Training in bangalore

    angularjs Training in bangalore

    angularjs Training in chennai

    automation anywhere online Training

    angularjs interview questions and answers

    ReplyDelete
  39. You truly did more than visitors’ expectations. Thank you for rendering these helpful, trusted, edifying and also cool thoughts on the topic to Kate.
    safety course in chennai

    ReplyDelete
  40. legaltestosteronebooster Wow I can say that this is another great article as expected of this blog.Bookmarked this site.

    ReplyDelete
  41. DevOps is currently a popular model currently organizations all over the world moving towards to it. Your post gave a clear idea about knowing the DevOps model and its importance.

    Good to learn about DevOps at this time.


    devops training in chennai | devops training in chennai with placement | devops training in chennai omr | devops training in velachery | devops training in chennai tambaram | devops institutes in chennai | devops certification in chennai | trending technologies list 2018

    ReplyDelete
  42. Long time no see your article. I am very glad when see your post. Click here sims 4 cheats to take part in the games. Thank you.

    ReplyDelete
  43. Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work.

    machine learning course in Chennai
    machine learning training center in Chennai
    machine learning certification course in Chennai
    Android training in chennai
    PMP training in chennai

    ReplyDelete
  44. Only here you will find the best slots.casino casino gaming Come in and win now.

    ReplyDelete
  45. Those rules moreover attempted to wind up plainly a decent approach to perceive that other individuals online have the indistinguishable enthusiasm like mine to get a handle on incredible arrangement more around this condition
    iosh safety course in chennai

    ReplyDelete
  46. Amazing article. Your blog helped me to improve myself in many ways thanks for sharing this kind of wonderful informative blogs in live. I have bookmarked more article from this website. Such a nice blog you are providing ! Kindly Visit Us @ Best Travels in Madurai | Tours and Travels in Madurai | Madurai Travels

    ReplyDelete
  47. Good job in presenting the correct content with the clear explanation. The content looks real with valid information. Good Work

    DevOps is currently a popular model currently organizations all over the world moving towards to it. Your post gave a clear idea about knowing the DevOps model and its importance.

    Good to learn about DevOps at this time.


    devops training in chennai | devops training in chennai with placement | devops training in chennai omr | devops training in velachery | devops training in chennai tambaram | devops institutes in chennai | devops certification in chennai | trending technologies list 2018 | Top 100 DevOps Interview Questions and Answers

    ReplyDelete
  48. This comment has been removed by the author.

    ReplyDelete
  49. Качественная лед лента разных цветов, герметичные и нет, я обычно беру в Экодио

    ReplyDelete
  50. Very nice post here thanks for it .I always like and such a super contents of these post.Excellent and very cool idea and great content of different kinds of the valuable information's. Machine learning training in chennai
    machine learning with python course in chennai
    machine learning course in chennai
    best training insitute for machine learning

    ReplyDelete
  51. One of the best content i have found on internet for Data Science training in Chennai .Every point for Data Science training in Chennai is explained in so detail,So its very easy to catch the content for Data Science training in Chennai .keep sharing more contents for Trending Technologies and also updating this content for Data Science and keep helping others.
    Cheers !
    Thanks and regards ,
    Data Science course in Velachery
    Data Scientists course in chennai
    Best Data Science course in chennai
    Top data science institute in chennai

    ReplyDelete
  52. Really useful information. Thank you so much for sharing.It will help everyone.Keep Post. RPA training in chennai | RPA training in Chennai with placement

    ReplyDelete
  53. Really useful information. Thank you so much for sharing.It will help everyone.Keep Post. RPA training in chennai | RPA training in Chennai with placement

    ReplyDelete
  54. Great casino, ever best online casino games you can safely put the top ten, with the new year already playing. At first I didn’t enter the topic as it is not hung with all sorts of bells and whistles I used to, but over time you realize that only good gaming games, bonuses and timely payments are needed in the casino, everything else interferes and distracts.

    ReplyDelete
  55. Really useful information. Thank you so much for sharing.It will help everyone.Keep Post. RPA training in chennai | RPA training in Chennai with placement

    ReplyDelete
  56. This is best one article so far I have read online, I would like to appreciate you for making it very simple and easy
    Regards,
    Devops Training in Chennai | Devops Certification in Chennai

    ReplyDelete
  57. Appericated the efforts you put in the content of Data Science .The Content provided by you for Data Science is up to date and its explained in very detailed for Data Science like even beginers can able to catch.Requesting you to please keep updating the content on regular basis so the peoples who follwing this content for Data Science can easily gets the updated data.
    Thanks and regards,
    Data Science training in Chennai
    Data Science course in chennai with placement
    Data Science certification in chennai
    Data Science course in Omr

    ReplyDelete
  58. I think things like this are really interesting. I absolutely love to find unique places like this. It really looks super creepy though!!
    Check out : big data training and placement in chennai
    big data hadoop training in chennai
    big data certification in chennai
    hadoop big data training in chennai

    ReplyDelete
  59. Appericated the efforts you put in the content of Data Science .The Content provided by you for Data Science is up to date and its explained in very detailed for Data Science like even beginers can able to catch.Requesting you to please keep updating the content on regular basis so the peoples who follwing this content for Data Science can easily gets the updated data.
    Thanks and regards,
    Data Science training in Chennai
    Data Science course in chennai with placement
    Data Science certification in chennai
    Data Science course in Omr

    ReplyDelete
  60. I am obliged to you for sharing this piece of information here and updating us with your resourceful guidance. Hope this might benefit many learners. Keep sharing this gainful articles and continue updating for us.
    redmi service center in vadapalani
    redmi service center in t nagar
    redmi service center in velachery

    ReplyDelete