Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have created web services before that are used by a small number of users but have a new project that would have lots of users.

For each user that uses the services, this is what they would do: 1) Call a method on the web service that calculates a "price" based on parameters passed by the user.

2) The actual method and algorithm for calculating and returning a "price" is not very complicated and runtime would be very quick, although a look up in a database table would be necessary for each call.

3) The problem is that this method could be called over and over again for each item that needs a price, and if lots of users are using the web service (I don't know an exact number, lets say 1,000 users, 10,000 users, whatever), I don't know what different things I need to think about in terms of how to manage high traffic, many different users trying to use the method at the same time over and over again, pulling data from a table over and over again.

So pretty much I would like some advice from someone who has experience with web services with high amounts of traffic and many different users, with the method pulling from a data base table over and over again, to explain to me steps/thing I need to think about when designing the service to avoid traffic congestion, at what point a certain number of users would start slowing the service down,or just things to think/worry about, etc.

Appreciate any help, thanks!

share|improve this question

closed as not a real question by gnat, MichaelT, Dynamic, Martijn Pieters, Jarrod Roberson Mar 26 '13 at 1:50

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

Can you give an example of the sorts of things that you would hit the database for? If it's different for each user on each call, then that'll be a problem. – Peter K. Mar 25 '13 at 20:06
1000 users is nothing. 10,000 users is still fewer users than seconds per day (86,400). A better measurement of usage would be hits per minute. – Brian Mar 25 '13 at 20:08
so the DB table would only be for finding a "rate" based on package type/weight. thats it. just a look up table – kevin Mar 25 '13 at 20:09
in terms of hits per minute, a user could be calling the function over and over again consecutively and lets say we have 10,000 users for a number, and they are using the function at the same and all of them are calling the function over and over again – kevin Mar 25 '13 at 20:12
How many users will use this concurrently? Even if you have a user population of 10,000 users, will all of them use this app continuously for an entire business day? The answer to this could easily be 'yes', depending on the problem being solved. – Dan Pichelman Mar 25 '13 at 20:15
up vote 2 down vote accepted

For item 2, you could definately use a cache to avoid going to the DB for every call, especially if the lookup data is not that volatile. The lifetime of the cache will depends on how long you keep the data. The cache could be refreshed as needed by your requirements. As a side note, most DBs cache results of common queries anyway.

Every service has limits. I would performance test the service to see how many calls it can handle. Definately build it stateless, then it is just a matter of how many calls a sec it needs to service. Say your requirements are 1,000 calls per second and your performance is 400 calls for 1 server. Then you need 3 servers to meet your requirements. Should be no problemto implement that sort of infrastructure.

You will not know for sure your service throughput until it is performance tested. Once you have baseline numbers, you can tweak the code or the environment to improve performance as needed.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.