O
O
Oleg Mikhailov2018-07-12 17:28:15
Java
Oleg Mikhailov, 2018-07-12 17:28:15

How to use max cpu for multithreaded task?

There is a service that now works in parallel with ~ 2000 clients and, accordingly, flows to them.
Previously, this was done through:

@Configuration
@EnableAsync
public class AsyncConfig  implements AsyncConfigurer {

  @Bean(name = "threadPoolTaskExecutor")
  public Executor threadPoolTaskExecutor() {
    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setCorePoolSize(Runtime.getRuntime().availableProcessors());
    executor.initialize();
    return executor;
  }

And in the controller, the method is marked with @Async("threadPoolTaskExecutor")
But in test mode, loading the system with about 100,000 requests from 2000 threads (via tomact: ab -n 1000000 -c 3000 " ) the percent is still only 36% loaded.
How to increase cpu usage and speed up execution this way?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2018-07-12
@Olegatorapp

A simple resource in itself is not a problem, but a blessing. The problem is the downtime of resources with a noticeable degradation of the service.
How long does it take for an answer? How long does it take to run 1 query at zero load? At what number of requests does the degradation of the service occur?
увеличить использование процессораAnd ускорить выполнениеthey don't have to go together. The processor may be idle because it is waiting for I/O, but also because it can easily cope with the current load.
In any case, you should ask not at the toaster, but at the profiler: where does the CPU time go, in what situations does the idle CPU appear, what is the ratio of idle time to useful work. If the service waits a long time for input-output, it is necessary to speed up the input-output, and not try to load the processor.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question