Java / Scala resource consumption and loading

I am developing a web application in Scala. This is a simple application that will receive port data from clients (JSON or ProtoBufs) and do some calculations using the database server, and then respond to the client with a JSON / Protobuf object.

This is not a very heavy application. 1000 lines of code max. It will create a stream for each client request. The time it takes right now between receiving a request and a response is 20 to 40 ms.

I need advice on what equipment / installation should be used to serve 3000+ such requests per second. I need to purchase equipment for my data center.

Anyone who has experience deploying Java applications to scale, consult. Should I use one large box with 2 - 4 Xeon 5500 with 32 GB of RAM or several smaller machines.

UPDATE - we do not have many customers. 3 to 4 of them. Requests will be from these 3 of them.

+4
source share
1 answer

If each request takes an average of 30 ms, a single core can only process 30 requests per second. Suppose your application scales linearly (the best scenario you can expect), then you need at least 100 cores to reach 3000 req / s. Which is more than 2-4 Xeon.

Worse, if you use an IO or DB application (like most useful applications), you will get sublinear scaling and you might need a lot more ...

So, the first thing to do is analyze and optimize the application. Here are some suggestions:

  • Creating a thread is expensive , try creating a limited number of threads and reuse them among requests (in java see ExecutorService , for example).
  • If you use IO-intensity: try to reduce the number of IO calls as much as possible, using the cache in memory and try not to block IO.
  • If the application is database dependent, consider caching and try a distributed solution if possible.
+2
source

Source: https://habr.com/ru/post/1384562/


All Articles