1

I would like to develop a Spring REST backend application with tomcat. I expect 1000-5000 active users. The users will create requests from clients(Android, web, Ios) to backend. Most of requests will create a simple db select.

  • How to calculate the limit of requests per second?
  • How to estimate the performance limits?
  • Should I use Microservice architecure or monolithic?

Thanks

Sisak
  • 559
  • 1
  • 4
  • 14

2 Answers2

1

Knowing the number of users is useful, but it is not enough.
At the very least you should be able to estimate the expected number of requests per second in the peek time and the required response time.

Once you know this the safest way to know the limits is to performance test it, either from a simple Java program or from something like JMeter.
For a typical tomcat performance take a look e.g. on this: how to handle 2000+ requests/sec on tomcat?

In general, Spring REST is not going to add much performance penalty and you also can have a cluster of tomcat instances, so the bottleneck might be somewhere else, e.g. in the DB.

As to the microservices question, start with the simplest approach (the monolith) and just make sure you follow standard SW development practices, i.e. have modules and classes etc. It is possible to move to the microservices later, but you should have a real reason for this, since it is more complex.

Community
  • 1
  • 1
Alexander
  • 2,761
  • 1
  • 28
  • 33
0

Use appropriate interceptor where you can do whatever you want. You can count number of threads (with a static variable) and reset every second or use a thread to do that.

@Component
public class RequestLoggingInterceptor extends OncePerRequestFilter
{

@Override
protected void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response, final FilterChain filterChain) throws ServletException, IOException {
    final long start = System.nanoTime();
    try {
        filterChain.doFilter(request, response);
    } finally {
        if( _logger.isInfoEnabled() ) {
            final long end = System.nanoTime();
            logger.info(buildMessage(request, end - start));
        }
    }
}

Microservice or monotlithic design is as per your requirement. If you have a big application and many modules and you want these modules to work independently and may have different database then you choose microservices. Microservices have a lot of advantages but only if you need them. For a basic operation normal monolithic is good (one rest project one static asset project and/or any other common project if needed).

surya
  • 2,581
  • 3
  • 22
  • 34
  • It would be a good idea use actuator on this example, You will be able to get the request per second using the endpoint metrics. Of course, you need to increase and decrease the counter programmaticaly. – Wilder Valera Jul 28 '17 at 15:57