This question already has an answer here:
I would like to know if it is possible to disable the HTTPSession
for an application server handling only web services RESTful.
I don't know if there are specific application servers or servlet containers designed to handle micro RESTful web services.
I think that disabling completely the session concept will give the following advantages:
- Better performances
- No risk to save data in the session breaking the concept of stateless of a RESTful webservice
- Less classes loaded by the classloader
- No unused information is saved in the session (for example the session id, session state)
- less access to synchronized blocks (I think that at least in the Session the value of lastAccessedTime is updated for every request and this should be done in a synchronized block)
If there is no application server or servlet container that can do that: Is there any other Java engine that can handle micro services without creating something similar to an HttpSession?
You can't completely disable the
HttpSession
.But you can ensure a
HttpSession
won't be created in your application. To do it, ensure the following methods are not being invoked (by yourself or by the frameworks you are using):HttpServletRequest.getSession()
HttpServletRequest.getSession(boolean)
withtrue
Microservices is an architecture design principle. If you want to use Spring, there's a guide you can follow.
You cannot disable HttpSession on a servlet container, like Tomcat.
Maybe Play framework would be a good approach for implementing your design.