0

I have created a web application that contains several large calculations. When a user uses the application to do these calculations, it takes less time (10-20 seconds). But when multiple users tries to do the calculations together, it takes a lot of time (10-20 minutes). When multiple users use the application for smaller tasks it works fast as expected. Problem occurs while larger calculations.

Why is this happening? Is this for processor's core/thread number? Or is this for the database keeping data locked during multiple requests?

What can be done to solve it?

Is there async await in Java like in C#, Javascript?

I have used Java, Spring, Hibernate, JPA, Tomcat, MySQL, Thymeleaf

Partho63
  • 3,117
  • 2
  • 21
  • 39
  • First thing to look is the MySQL error log, locks can be viewed by a simple query second look at the query plan if all the right indexes were used. Rebuilding indexes can also help – nbk Jun 03 '23 at 06:54

1 Answers1

1

Based on the components you listed, your application is too complex to answer this question without more details. Use a profiler and figure out where the time is being spent.

Regarding async await, Java has extensive multithreading support via java.lang.concurrent library, but only primitive instructions (wait/yield/notify) at language level (that you most likely won't use). How to asynchronously call a method in Java You can use Executors to create a threadpool-backed ExecutorService and queue up tasks for it to execute. You can use CompletableFuture to use a built-in threadpool. Or, since you use Spring, you can use Spring's @Async annotation.

ykaganovich
  • 14,736
  • 8
  • 59
  • 96
  • Each thread that is accessing the database needs to have its own connection. How many connections are there? – Rick James Jun 04 '23 at 02:20