You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@groovy.apache.org by Aplomb Chen <ap...@gmail.com> on 2016/06/19 13:00:56 UTC

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?


Aplomb

Best regards

Re: Groovy hot deploy in production

Posted by Aplomb Chen <ap...@gmail.com>.
Thanks, onStart and onStop are a good hit for my cases.

On Tue, Jun 21, 2016 at 10:17 PM, Erwin Müller <er...@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" <ap...@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?
>
>
>
> Aplomb
>
>
>
> Best regards
>
>
>
> --
> Erwin Müller - erwin.mueller@deventm.org
> Software Entwickler - (+49) 01577-9505569
> Pgp - https://pgp.mit.edu/pks/lookup?op=get&search=0x02E820911DD910FD
> Meine Seite - http://www.mueller-public.de/
> ANRI - http://www.anr-institute.com/
>

Re: Groovy hot deploy in production

Posted by Alessio Stalla <al...@gmail.com>.
In Portofino applications we allow to hot reload Groovy code using
GroovyScriptEngine. It is great for development and handy for fixing quick
issues in production too, but if it's mission critical I wouldn't rely on
it yet. Even if it has improved much over time (thanks to Jochen's work!)
sometimes it can happen that something is not properly updated - be it for
some hard to find Groovy bug still left around, or frameworks caching
classes and not properly releasing them, or your own code keeping objects
around e.g. in the HTTP session. So the occasional application server
reload is still needed even if it's quite rare. I'm talking about
relatively low traffic business type applications with maybe hundreds of
users top. For a busy network application with a lot of framework code and
frequent hot reloads things are likely to get worse quicker.

On 21 June 2016 at 20:40, Erwin Müller <er...@deventm.org> wrote:

> Just have a data storage for persistent data, and let the Groovy code
> access that data in an atomic way.
> Just a simple synchronized map would be sufficient as the data storage.
> That way, you won't need to storage any data in your Groovy code.
> It's just important to use atomic types like primitive types (int, float)
> or AtomicInt, AtomicBoolean, and read-only types, like String, InetAddress,
> joda.DateTime.
> Later in the development you can exchange the simple synchronized map with
> MemotyDb if you want to.
>
> For example,
>
> class DataStorage {
>     private Map storage;
>     DataStorage() {
>         this.storage=Collections.synchronizedMap(new HashMap());
>     }
>     public void addUser(name);
>     public void setUserPassword(name, password);
>     public String getUserPassword(name);
>     public void setUserTCP(name, tcp);
>     public String getUserTCP(name);
>     public void setUserUDP(name, udp);
>     public String getUserUDP(name);
> }
>
> Tue Jun 21 2016 20:01:42 CEST from "Aplomb Chen" <ap...@gmail.com> Subject:
> Re: Groovy hot deploy in production
> 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
> <ht...@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
>> <ht...@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
>>> <ht...@gmailcom>> 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?
>>>
>>>
>>>
>>> Aplomb
>>>
>>>
>>>
>>> Best regards
>>>
>>>
>>>
>>>
>>> --
>>> Erwin Müller - erwin.mueller@deventm.org
>>> <ht...@deventm.org>
>>> Software Entwickler - (+49) 01577-9505569
>>> Pgp - https://pgp.mit.edu/pks/lookup?op=get&search=0x02E820911DD910FD
>>> Meine Seite - http://www.mueller-public.de/
>>> <http://wwwmueller-public.de/>
>>> ANRI - http://www.anr-institute.com/
>>>
>>
>
>
> --
> Erwin Müller - erwin.mueller@deventm.org
> Software Entwickler - (+49) 01577-9505569
> Pgp - https://pgp.mit.edu/pks/lookup?op=get&search=0x02E820911DD910FD
> Meine Seite - http://www.mueller-public.de/
> ANRI - http://www.anr-institute.com/
>

Re: Groovy hot deploy in production

Posted by Erwin Müller <er...@deventm.org>.
Just have a data storage for persistent data, and let the Groovy code access
that data in an atomic way.
Just a simple synchronized map would be sufficient as the data storage.
That way, you won't need to storage any data in your Groovy code.
It's just important to use atomic types like primitive types (int, float) or
AtomicInt, AtomicBoolean, and read-only types, like String, InetAddress,
joda.DateTime.
Later in the development you can exchange the simple synchronized map with
MemotyDb if you want to.  

For example,  

class DataStorage {
    private Map storage;
    DataStorage() {
        this.storage=Collections.synchronizedMap(new HashMap());
    }
    public void addUser(name);
    public void setUserPassword(name, password);
    public String getUserPassword(name);
    public void setUserTCP(name, tcp);
    public String getUserTCP(name);
    public void setUserUDP(name, udp);
    public String getUserUDP(name);
}  
>  Tue Jun 21 2016 20:01:42 CEST from "Aplomb Chen" <ap...@gmail.com> 
>Subject: Re: Groovy hot deploy in production
>
>      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
><do...@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
>><er...@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"
>>>><ap...@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?  
>>>>
>>>>   
>>>>
>>>>Aplomb  
>>>>
>>>>   
>>>>
>>>>Best regards  
>>>>
>>>>  
>>>>
>>>>
>>>>
>>>>  

>>>  
>>>
>>>    
>>>
>>>   
>>>
>>>-- 
>>>Erwin Müller - erwin.mueller@deventm.org
>>>Software Entwickler - (+49) 01577-9505569
>>>Pgp - https://pgp.mit.edu/pks/lookup?op=get&search=0x02E820911DD910FD
>>>Meine Seite - http://www.mueller-public.de/
>>>ANRI - http://www.anr-institute.com/  
>>>
>>>  

>>  
>>
>>  
>>
>>  
>>
>>  

>  
>
>  
>
>  
>
>
>
>  

  


   

-- 
Erwin Müller - erwin.mueller@deventm.org
Software Entwickler - (+49) 01577-9505569
Pgp - https://pgp.mit.edu/pks/lookup?op=get&search=0x02E820911DD910FD
Meine Seite - http://www.mueller-public.de/
ANRI - http://www.anr-institute.com/

Re: Groovy hot deploy in production

Posted by Aplomb Chen <ap...@gmail.com>.
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 <er...@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" <ap...@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?
>>
>>
>>
>> Aplomb
>>
>>
>>
>> Best regards
>>
>>
>>
>> --
>> Erwin Müller - erwin.mueller@deventm.org
>> Software Entwickler - (+49) 01577-9505569
>> Pgp - https://pgp.mit.edu/pks/lookup?op=get&search=0x02E820911DD910FD
>> Meine Seite - http://www.mueller-public.de/
>> ANRI - http://www.anr-institute.com/
>>
>

Re: Groovy hot deploy in production

Posted by Domingo Suárez Torres <do...@gmail.com>.
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 <er...@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" <ap...@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?
>
>
>
> Aplomb
>
>
>
> Best regards
>
>
>
> --
> Erwin Müller - erwin.mueller@deventm.org
> Software Entwickler - (+49) 01577-9505569
> Pgp - https://pgp.mit.edu/pks/lookup?op=get&search=0x02E820911DD910FD
> Meine Seite - http://www.mueller-public.de/
> ANRI - http://www.anr-institute.com/
>

Re: Groovy hot deploy in production

Posted by Erwin Müller <er...@deventm.org>.
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" <ap...@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?  
>
>   
>
>Aplomb  
>
>   
>
>Best regards  
>
>  
>
>
>
>  

  


   

-- 
Erwin Müller - erwin.mueller@deventm.org
Software Entwickler - (+49) 01577-9505569
Pgp - https://pgp.mit.edu/pks/lookup?op=get&search=0x02E820911DD910FD
Meine Seite - http://www.mueller-public.de/
ANRI - http://www.anr-institute.com/