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
- Accept Incoming POST request. DTO object at a save endpoint.
- Application will then validate the DTO and return relevant Error message if it is invalid.
- Convert to a database entity object
- Save entity to a Postgres database.
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
- Does this look like a good approach, are there any pitfalls I should look out for?
- Maybe you have solved a similar issue in a better / different way?
- Could reactive streams help in anyway?
- What internal Java libraries should I use for this? My
thinking was to go with Java's LinkedList
Queue<SomeDto> myQ = new LinkedList<SomeDto>(); )
for queueing internally?