I am developing chat servers which need hold user information in server memory like the tcp or udp channels and other user session data. 

Hot deployments will be useful that I can keep the user information in memory and upgrade the business code for new features. So that those chat users won't need re-login again, otherwise I need restart chat servers for the upgrade which will easily cause login storm.

Currently my plan is using groovy for hot deploy, I will do switching GroovyClassLoader every time when I need upgrade code, which means in groovy code, I can not hold any memory, I think the advantage is I can control to upgrade groovy scripts after the code is updated on server and demand our developers not hold any memory in groovy scripts, this is like how PHP does, right?

For further thinking, to resolve the NOT hold any memory demand, I am thinking about implement MemoryDB (May like Redis, but much more simpler) for groovy scripts, so that developers can save objects to MemoryDB in runtime. 

Do you think this is a reasonable design? Please advice, much appreciated! 

On Tue, Jun 21, 2016 at 11:54 PM, Domingo Suárez Torres <domingo.suarez@gmail.com> wrote:
I always avoid hot deployments, I prefer to have multiple running JVMs and a proxy or load balancer in front.

On Tue, Jun 21, 2016 at 9:18 AM Erwin Müller <erwin.mueller@deventm.org> wrote:

Why not have start and stop hooks for such stuff?

Have an interface with onStart() and onStop() methods, and call them when you load and unload a class.

If you really need modularity, use OSGi.

Regards, Erwin.

Sun Jun 19 2016 15:00:56 CEST from "Aplomb Chen" <aplomb.chen@gmail.com> Subject: Groovy hot deploy in production

Hi Guys, 


Will you use groovy hot deploy in production environment? Is it reliable to do so?


I am worried that it may have issue when you are doing below, 

1, Defined a Array as class attribute, make it has 10000 objects, next time code hot deploy that the array is erased in code, then that must be an memory leak, right?

2, If you execute a periodic timertask in a groovy, next time code hot deployed, if the timetask is no longer needed from your code, but the started timertask will still be running, right?


If we demands developers avoid using class attributes or starting any thread thing as a development rule, will hot deploy still be good for production?




Best regards