c# - WCF Service for many concurrent clients and database access -


I'm new to WCF services and I wonder what would be the best way to deal with the following.

I have a lot of customers (~ 200 - 500) who are continuously continuing all my service requests during the working day. Most requests include the query of an underlying database to feed the correct response back.

The relation I have is the possible number of database connections generated from incoming requests. If all the customers make a request together then the database server will be hit hard if possible, so I would like to avoid a silly number of databases.

Would it be better to restrict the number of concurrent connections for WCF service and therefore reduce the possible number of unknowable database connections?

I have seen service on making a singleton which spawns threads for database transactions, so I can control the number of threads, but is it a redundancy and connection to the service Will restrict?

Many thanks for any advice. As mentioned earlier - WCF has a built-in service throttling capability, which you can use to connect to the server. You can tune in to prevent that your database server will flood with many requests at once.

The default is:

  & lt; ServiceThrottling maxConcurrentCalls = "16" maxConcurrentSessions = "10" maxConcurrentInstances = "26" />  

See for more information.

This means that up to 16 calls are concurrently controlled by WCF - that is, if allows your WCF service class to make multiple calls at one time!

Unlike Marcos, I have to be a simple WCF service class for general best practice, and use it in every call fashion - eg. Each incoming request will be made a new form of your WCF service class, which is defined by the throttling behavior of your service and controlled by the WCF Runtime.

If you create your WCF Service class is a singleton, you have to set your ConcurrencyMode to multiple - but then you do not have to be very careful that changing the thread of two classes into one Change the same value to the other; Multi threading Safe programming is a big challenge! Or you do not set multiple to concurrency mode, but then your one and only WCF service class instance can handle the request in only one serial fashion at one time - not at a time - not too scalable!

A service example per-call and per request is definitely a very easy way to go. This place with throttling and ado. Net connection pooling makes a very powerful and well-behaved environment!

See also for further expansion.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -