I'm looking to build a Java11 Spring boot application. The application is to handle very large throughput (will have peaks and low traffic)
The happy path of the application looks like this.
Conceptually its fairly straight forward. The steps roughly look like this
The potential issue we have with this application is that It's going to do database saves per each request its alot of individual saves. The database connection pools can quickly run out the more connections that are made.
My alternative approach looks like this
Im looking to return a status 200 once the incoming DTO passes validation and is queued up in a memory queue.
There is no external blocking here and should the database go down - meaning the internal queue will give some redundancy.
So some questions / ideas
Queue<SomeDto> myQ = new
LinkedList<SomeDto>(); )
for queueing internally?What happens if the app fails with data in the internal queue ? Or if there is an overflow of save operations in memory ?
If you want to build something more robust, you may consider an event-log solution (based on Kafka for example) with consumers populating the database (Kafka would replace your internal queue).
However, it is difficult to really answer your question here since many other elements must be taken into consideration.
I would suggest you to read a book like Designing Data-Intensive Applications: it is definitively a valuable resource and it will help you to design a reliable solution based on your needs and your context.