I am developing an MVC spring web application and I would like to store my users actions (what they click, etc.) in a database for offline analysis. Let say that the action is a tuple (long userId, long actionId, Date timestamp). I am not interested in the actions of my users, but I take this as an example.
I expect a lot of action from a few (different) users in a couple of minutes (in seconds). Therefore, processing time is critical.
In my current implementation, I defined a data source with a connection pool to store actions in the database. I call the service from the controller request method, and this service calls the DAO, which stores the action in the database.
This implementation is inefficient because it expects a call from the controller and all the way to the database to be executed to return a response to the user. So I was thinking of wrapping this "save action" in a stream so that the response to the user would be faster. To receive the answer, the stream does not need to be completed.
I have no experience in these massive, parallel and mission critical applications. Therefore, any feedback / comments will be very helpful.
Now my questions are:
How would you create such a system? Will you implement the service and then transfer it to the stream, called with each action?
What should i use? I checked spring Batch and this JobLauncher, but I'm not sure if this is right for me.
What happens when there are concurrent calls in the controller, service, DAO, and data source layer?
In more general terms, what are the best practices for designing such applications?
Thank you for your help!
source share