Project

General

Profile

Deployment to Heroku

Added by Hristo Hristov over 12 years ago

I am trying to figure out if deployment to Heroku is possible. They support any java application, but I am worried about the sessions with JWt.

As it is written in http://devcenter.heroku.com/articles/java-faq :

The Heroku routing infrastructure does not support “sticky sessions”. Requests from clients will be distributed randomly to all dynos running your application.

A "dyno" is one of the many servers that can handle a client request. It can be different every time. This is similar to the Google app engine and happens to be the case with many others.

Is this a problem with JWt? How is the session stored/tracked and is it a problem if after starting the JWt application every subsequent request is handled by different server?

I am planning a project with many concurrent users and I want to make it easy to scale using Heroku, GAE or similar platform. I would like to use JWt if this is possible.

Thank you!


Replies (7)

RE: Deployment to Heroku - Added by Koen Deforche over 12 years ago

Hey Hristo,

Yes, this means that deployment to heroku will not work.

The story is similar for GAE --- although they support sticky sessions this is costly in terms of "budgets" you get allocated.

Sticky sessions, as implemented in JWt which does not rely on cookies but on URL-encoded requests, would actually be easy to support (all load balancer software supports this) --- unfortunately, being able to safely rely on URL-encoding is exceptional for a web framework, and thus less known.

Regards,

koen

RE: Deployment to Heroku - Added by Wim Dumon over 12 years ago

Dear Hristo,

I would like to add to that: you should ask heroku for websockets support in the servlet container. It is my guess that when they have the proper infrastructure for websocket support, Wt will be able to run on Heroku.

Best regards,

Wim.

RE: Deployment to Heroku - Added by Hristo Hristov over 12 years ago

Hey Koen,

it's sad that this is the case, as heroku is pretty good service with some innovative ideas, as deploying by pushing your java code to a git repo, and automatic building with maven.

I hope that one day they will support sticky sessions relying on the url at least. Currently, the requests are routed to the application nodes using round-robin. Still, maybe this can be solved my serializing the sessions to a database, but this would be slow I suppose. I think there is similar problem with other frameworks too, for example the scala's lift, which is also stateful.

Koen Deforche wrote:

Hey Hristo,

Yes, this means that deployment to heroku will not work.

The story is similar for GAE --- although they support sticky sessions this is costly in terms of "budgets" you get allocated.

Sticky sessions, as implemented in JWt which does not rely on cookies but on URL-encoded requests, would actually be easy to support (all load balancer software supports this) --- unfortunately, being able to safely rely on URL-encoding is exceptional for a web framework, and thus less known.

Regards,

koen

RE: Deployment to Heroku - Added by Hristo Hristov over 12 years ago

Hey Wim,

with heroku you can use any servlet container, as "you bring it with you", so websockets can be supported, but I do not see how is this useful to Wt?

Wim Dumon wrote:

Dear Hristo,

I would like to add to that: you should ask heroku for websockets support in the servlet container. It is my guess that when they have the proper infrastructure for websocket support, Wt will be able to run on Heroku.

Best regards,

Wim.

RE: Deployment to Heroku - Added by Koen Deforche over 12 years ago

Hey Hristo,

Unfortunately, the servlet spec does not yet support WebSockets. But when they do, they will need to acknowledge the need to keep a long-lived connection, which is contingent on keeping the session on a single instance.

WebSockets does not combine very well with the request-and-forget approach.

Regards,

koen

RE: Deployment to Heroku - Added by Hristo Hristov over 12 years ago

Thanks, Koen,

know it is more clear to me. I see that with the approach of JWt there are many advantages which I definitely want to keep.

I asked the question regarding heroku, because I want to create an application which is able to scale very big.

How would you go with JWt in this case? Say we want to serve for example 10k users at the same time at peak. Heroku/GAE are not an option.

What would you do?

Thanks!

Koen Deforche wrote:

Hey Hristo,

Unfortunately, the servlet spec does not yet support WebSockets. But when they do, they will need to acknowledge the need to keep a long-lived connection, which is contingent on keeping the session on a single instance.

WebSockets does not combine very well with the request-and-forget approach.

Regards,

koen

RE: Deployment to Heroku - Added by Koen Deforche over 12 years ago

Hey,

I would deploy on one 1-N servers behind a reverse proxy like HAproxy as a load balancer configured to support sticky sessions.

As "servers" you could consider VPSes or dedicated hardware. If you are going the VPS route, you may also consider using Amazon.

As to the application server, if you are not using server push, you could use a well-tested Servlet 2.5 container (Tomcat 5/6 or Jetty). If you need serverpush you will want to try which one of the Servlet 3.0 containers works best.

Regards,

koen

    (1-7/7)