Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > chron overhead

Reply
Thread Tools

chron overhead

 
 
Roedy Green
Guest
Posts: n/a
 
      11-19-2008
I have always avoided writing Java programs than run all the time and
sporadically wake up to do something, e.g. test if a website is up,
check for mail, do a backup ...

I figured the overhead would be unacceptable. Though I never tested
it. Has anyone ever measured just how much of a drain such a sleeping
program puts on resources?
--
Roedy Green Canadian Mind Products
http://mindprod.com
Your old road is
Rapidly agin'.
Please get out of the new one
If you can't lend your hand
For the times they are a-changin'.
 
Reply With Quote
 
 
 
 
Owen Jacobson
Guest
Posts: n/a
 
      11-19-2008
On Nov 19, 11:48*am, Roedy Green <see_webs...@mindprod.com.invalid>
wrote:
> I have always avoided writing Java programs than run all the time and
> sporadically wake up to do something, e.g. test if a website is up,
> check for mail, do a backup ...
>
> I figured the overhead would be unacceptable. Though I never tested
> it. *Has anyone ever measured just how much of a drain such a sleeping
> program puts on resources?


I run Tomcat to host Hudson and JIRA for my own development on a linux
machine stashed in a corner. When no builds are running and I'm not
actively fiddling with JIRA issues, the machine's load averages are
effectively 0.00 0.00 0.00. I was a little leery of having a Java
server running constantly for pretty much the same reasons, but it
actually works rather well.

For reference:
JAVA_OPTS="-Djava.awt.headless=true -Xmx512M \
-Dorg.apache.jasper.runtime.BodyContentImpl.LIMIT_B UFFER=true"
JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.10

Care of ps(1), the rss and vsize:
rss = 111800 (111 MB), vsize = 695512 (696 MB)
which makes it by far the largest process (for both resident and
virtual size) on the system, but with several GB of RAM I can afford
100MB.

-o
 
Reply With Quote
 
 
 
 
Tom Anderson
Guest
Posts: n/a
 
      11-19-2008
On Wed, 19 Nov 2008, Owen Jacobson wrote:

> On Nov 19, 11:48*am, Roedy Green <see_webs...@mindprod.com.invalid>
> wrote:
>
>> I have always avoided writing Java programs than run all the time and
>> sporadically wake up to do something, e.g. test if a website is up,
>> check for mail, do a backup ...
>>
>> I figured the overhead would be unacceptable.


I'd also avoid it, but not out of concern for efficiency - for robustness.
With a sleeping-looping program, if it crashes or gets wedged or
something, it stops doing its job. With a program that does the job once
and exits, but which is scheduled by cron or similar, the worst a crash or
hang can do is clobber one run. It would take a failure of cron itself to
stop future runs, and cron is something that i'm willing to bet the farm
on.

I guess you could use some external utility to monitor your looping
program and restart it if it crashes. I think you can do that with init on
unix (?), or launchd on a Mac, or you can just write a shell script which
invokes the program in a loop. Doesn't really help with hangs, though. You
could use some sort of watchdog mechanism for that.

>> Though I never tested it. *Has anyone ever measured just how much of a
>> drain such a sleeping program puts on resources?

>
> I run Tomcat to host Hudson and JIRA for my own development on a linux
> machine stashed in a corner. When no builds are running and I'm not
> actively fiddling with JIRA issues, the machine's load averages are
> effectively 0.00 0.00 0.00. I was a little leery of having a Java
> server running constantly for pretty much the same reasons, but it
> actually works rather well.
>
> For reference:
> JAVA_OPTS="-Djava.awt.headless=true -Xmx512M \
> -Dorg.apache.jasper.runtime.BodyContentImpl.LIMIT_B UFFER=true"
> JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.10
>
> Care of ps(1), the rss and vsize:
> rss = 111800 (111 MB), vsize = 695512 (696 MB)
> which makes it by far the largest process (for both resident and
> virtual size) on the system, but with several GB of RAM I can afford
> 100MB.


I'm slightly surprised it uses 100 MB of memory even when not running. Is
that because there's nothing else running on that machine, or at any rate,
not a lot of memory pressure? Would that get paged out if there was, or is
it some kind of pinned/wired memory?

tom

--
uk.local groups TO BE RENAMED uk.lunatic.fringe groups
 
Reply With Quote
 
Owen Jacobson
Guest
Posts: n/a
 
      11-19-2008
On Nov 19, 1:12*pm, Tom Anderson <t...@urchin.earth.li> wrote:
> On Wed, 19 Nov 2008, Owen Jacobson wrote:
> > On Nov 19, 11:48*am, Roedy Green <see_webs...@mindprod.com.invalid>
> > wrote:

>
> >> I have always avoided writing Java programs than run all the time and
> >> sporadically wake up to do something, e.g. test if a website is up,
> >> check for mail, do a backup ...

>
> >> I figured the overhead would be unacceptable.

>
> I'd also avoid it, but not out of concern for efficiency - for robustness..
> With a sleeping-looping program, if it crashes or gets wedged or
> something, it stops doing its job. With a program that does the job once
> and exits, but which is scheduled by cron or similar, the worst a crash or
> hang can do is clobber one run. It would take a failure of cron itself to
> stop future runs, and cron is something that i'm willing to bet the farm
> on.
>
> I guess you could use some external utility to monitor your looping
> program and restart it if it crashes. I think you can do that with init on
> unix (?), or launchd on a Mac, or you can just write a shell script which
> invokes the program in a loop. Doesn't really help with hangs, though. You
> could use some sort of watchdog mechanism for that.
>
>
>
> >> Though I never tested it. *Has anyone ever measured just how much of a
> >> drain such a sleeping program puts on resources?

>
> > I run Tomcat to host Hudson and JIRA for my own development on a linux
> > machine stashed in a corner. When no builds are running and I'm not
> > actively fiddling with JIRA issues, the machine's load averages are
> > effectively 0.00 0.00 0.00. I was a little leery of having a Java
> > server running constantly for pretty much the same reasons, but it
> > actually works rather well.

>
> > For reference:
> > JAVA_OPTS="-Djava.awt.headless=true -Xmx512M \
> > *-Dorg.apache.jasper.runtime.BodyContentImpl.LIMIT_B UFFER=true"
> > JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.10

>
> > Care of ps(1), the rss and vsize:
> > rss = 111800 (111 MB), vsize = 695512 (696 MB)
> > which makes it by far the largest process (for both resident and
> > virtual size) on the system, but with several GB of RAM I can afford
> > 100MB.

>
> I'm slightly surprised it uses 100 MB of memory even when not running. Is
> that because there's nothing else running on that machine, or at any rate,
> not a lot of memory pressure? Would that get paged out if there was, or is
> it some kind of pinned/wired memory?
>
> tom


There's a lot of crap running on that machine (apache2, tomcat, mysql
for some webapps, postgresql for my own apps, slapd, sshd, and a few
long-standing screen sessions) for one user, but it's not busy by any
stretch. The load average rarely breaks 1.0.

Computing range(1, 0x0FFFFFFF) in python (which allocates a really
huge array) forces Tomcat's resident size down to 5916 (6 MB). It also
beats the crap out of the CPU.

-o
 
Reply With Quote
 
Tom Anderson
Guest
Posts: n/a
 
      11-19-2008
On Wed, 19 Nov 2008, Owen Jacobson wrote:

> On Nov 19, 1:12*pm, Tom Anderson <t...@urchin.earth.li> wrote:
>> On Wed, 19 Nov 2008, Owen Jacobson wrote:
>>> On Nov 19, 11:48*am, Roedy Green <see_webs...@mindprod.com.invalid>
>>> wrote:

>>
>>>> I have always avoided writing Java programs than run all the time and
>>>> sporadically wake up to do something, e.g. test if a website is up,
>>>> check for mail, do a backup ...
>>>>
>>>> I figured the overhead would be unacceptable.
>>>>
>>>> Though I never tested it. *Has anyone ever measured just how much of a
>>>> drain such a sleeping program puts on resources?
>>>
>>> I run Tomcat to host Hudson and JIRA for my own development on a linux
>>> machine stashed in a corner. When no builds are running and I'm not
>>> actively fiddling with JIRA issues, the machine's load averages are
>>> effectively 0.00 0.00 0.00. I was a little leery of having a Java
>>> server running constantly for pretty much the same reasons, but it
>>> actually works rather well.
>>>
>>> Care of ps(1), the rss and vsize: rss = 111800 (111 MB), vsize =
>>> 695512 (696 MB) which makes it by far the largest process (for both
>>> resident and virtual size) on the system, but with several GB of RAM I
>>> can afford 100MB.

>>
>> I'm slightly surprised it uses 100 MB of memory even when not running.
>> Is that because there's nothing else running on that machine, or at any
>> rate, not a lot of memory pressure? Would that get paged out if there
>> was, or is it some kind of pinned/wired memory?

>
> There's a lot of crap running on that machine (apache2, tomcat, mysql
> for some webapps, postgresql for my own apps, slapd, sshd, and a few
> long-standing screen sessions) for one user, but it's not busy by any
> stretch. The load average rarely breaks 1.0.
>
> Computing range(1, 0x0FFFFFFF) in python (which allocates a really huge
> array) forces Tomcat's resident size down to 5916 (6 MB).


Okay, interesting and reassuring. Thanks for the info. I wonder what's
preserving the last 6 MB.

> It also beats the crap out of the CPU.


I have in the past used exponentiation of bignums in python to dry my
socks!

tom

--
uk.local groups TO BE RENAMED uk.lunatic.fringe groups
 
Reply With Quote
 
Martin Gregorie
Guest
Posts: n/a
 
      11-19-2008
> I'd also avoid it, but not out of concern for efficiency - for
> robustness.
>
> With a sleeping-looping program, if it crashes or gets
> wedged or something, it stops doing its job. With a program that does
> the job once and exits, but which is scheduled by cron or similar, the
> worst a crash or hang can do is clobber one run. It would take a failure
> of cron itself to stop future runs, and cron is something that i'm
> willing to bet the farm on.
>

Likewise, though as my Java cron job runs once a day for typically less
than 30 seconds, its arguable whether it deserves to occupy memory space
for the remaining 23 hours 59 minutes and 30 seconds. Running it more
frequently than once a day would gain me very little.

I think there are other reasons for using cron that are more compelling:
the program has been a lot easier to test than a permanently resident
version would be and I didn't see the need to build functionality into it
that's already provided by cron.

> I guess you could use some external utility to monitor your looping
> program and restart it if it crashes. I think you can do that with init
> on unix (?)
>

True. If it was started as a system daemon at boot time it would be
automatically restarted if it crashed, but this mechanism can't spot it
looping or getting wedged. If your *nix has the SVR4 style daemon
management tools built round /etc/rc.d/* you can use the 'service'
command to stop, start, or restart it and report its status. Dead/alive
status reporting is built in but finding out any more about your server
would require a status querying command line client and a matching
transaction in the server.


--
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |
 
Reply With Quote
 
Mike Schilling
Guest
Posts: n/a
 
      11-19-2008
Tom Anderson wrote:
>
> I have in the past used exponentiation of bignums in python to dry
> my
> socks!


Heats up the processor, causing the fan to run continuously?


 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      11-19-2008
Tom Anderson wrote:
> On Wed, 19 Nov 2008, Owen Jacobson wrote:
>> Care of ps(1), the rss and vsize:
>> rss = 111800 (111 MB), vsize = 695512 (696 MB)
>> which makes it by far the largest process (for both resident and
>> virtual size) on the system, but with several GB of RAM I can afford
>> 100MB.

>
> I'm slightly surprised it uses 100 MB of memory even when not running.
> Is that because there's nothing else running on that machine, or at any
> rate, not a lot of memory pressure? Would that get paged out if there
> was, or is it some kind of pinned/wired memory?


Java app servers are notorious memory pigs.

But considering that 100 MB of standard PC RAM is about 1 USD, then ...

Arne
 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      11-19-2008
Tom Anderson wrote:
> On Wed, 19 Nov 2008, Owen Jacobson wrote:
>> On Nov 19, 11:48 am, Roedy Green <see_webs...@mindprod.com.invalid>
>> wrote:
>>> I have always avoided writing Java programs than run all the time and
>>> sporadically wake up to do something, e.g. test if a website is up,
>>> check for mail, do a backup ...
>>>
>>> I figured the overhead would be unacceptable.

>
> I'd also avoid it, but not out of concern for efficiency - for
> robustness. With a sleeping-looping program, if it crashes or gets
> wedged or something, it stops doing its job. With a program that does
> the job once and exits, but which is scheduled by cron or similar, the
> worst a crash or hang can do is clobber one run. It would take a failure
> of cron itself to stop future runs, and cron is something that i'm
> willing to bet the farm on.
>
> I guess you could use some external utility to monitor your looping
> program and restart it if it crashes. I think you can do that with init
> on unix (?), or launchd on a Mac, or you can just write a shell script
> which invokes the program in a loop. Doesn't really help with hangs,
> though. You could use some sort of watchdog mechanism for that.


If using a Java app server he would also get robustness through a
separation of the container code and the app code.

Arne
 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      11-19-2008
Roedy Green wrote:
> I have always avoided writing Java programs than run all the time and
> sporadically wake up to do something, e.g. test if a website is up,
> check for mail, do a backup ...
>
> I figured the overhead would be unacceptable. Though I never tested
> it. Has anyone ever measured just how much of a drain such a sleeping
> program puts on resources?


A handwritten Java daemon would use very little resources, but
would be a bit vulnerable.

I would suggest following Owens model and run it in Tomcat.

It would user very little CPU, use some memory but memory
is cheap and it could be done rather robust.

Arne
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Chron software for windows JohnO NZ Computing 6 08-11-2009 07:35 AM
Overhead of 4-port over 2-port SRAM John T. Goodman VHDL 0 01-25-2005 04:27 PM
DoS attack and IP Accounting OverHead. Gary Cisco 4 02-28-2004 08:05 PM
Lowering Processing Overhead Radley Cisco 0 01-24-2004 04:30 PM
IP NBAR - What kind of overhead does it cause?? Douw Gerber Cisco 1 11-22-2003 09:27 AM



Advertisments