our application is built on Spring Boot 2 (spring-data, JPA, Hibernate, Postgres, tomcat). Performance of an application is very bad because there is a lot of requests in time (for instance 2000 in 1 second). We are aware we need to rewrite it in future. But my question is if there is some solution which improves performance and executing a lot of requests without big changes in the code? Thank you for any advice.
2 Answers
Its a broad question but some techniques that come in mind:
1) Optimistic locking. Thanks to that you do not need to physically lock tables / rows thus your concurring requests do not get queued and stack up. You still would get OptimisticLockExceptions and will need to handle them but you get some performance benefits on the flip-side.
2) Try to avoid long methods wrapped in transactions that may lock certain data for more then needed. You may need to think about setting your @Transactionl methods with PROPAGATION=REQUIRES_NEW and making them shorter in general.
3) Try to test around with timeouts on your queries so that they do not hang for too long when blocked etc.