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!
6
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.