Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Script slow only when run as scheduled tasks on Windows Server

by Tabla (Initiate)
on Nov 30, 2011 at 07:07 UTC ( [id://940786]=perlquestion: print w/replies, xml ) Need Help??

Tabla has asked for the wisdom of the Perl Monks concerning the following question:

I have a script (Strawberry Perl) that reads certain records from a remote database server and stores results in a local mysql databasae after some processing. The script is invoked by double-clicking a batch file (like "perl mytask.pl")

Everything works as expected when run from the command prompt. Performance is fine with around 700 records per second.

Running the same batch as a scheduled script on the machine (virtualized Windows Server 2008 R2 on VMware ESX, Resources plentiful) slows the retrieval of data down to about 10 records per second).

Further processing of data (only locally now) works fine as before. Both CPU load and network load remain very low (close to idle) when the task runs as scheduled. Running the task interactive consumes ~50 % of CPU which seems plausible.

Any hint why running as scheduled has such a terrible effect on performance?

Greetings from Wiesbaden, Germany - Tabla

Replies are listed 'Best First'.
Re: Script slow only when run as scheduled tasks on Windows Server
by Anonymous Monk on Nov 30, 2011 at 08:19 UTC

    Any hint why running as scheduled has such a terrible effect on performance?

    Seems to me the emulation/virtualization is slowing things down, I have no idea why, probably due to the design or a bug :/

    Last time I noticed slower performance than I expected, I was printing/logging lots to STDOUT, which cmd.exe was really slow to show, slower than database access

    Running with wperl.exe or redirecting STDOUT to a file  >log.txt sped up the process more than double, maybe you can try that?

    Another thing I've seen is if your video driver doesn't load, but the generic one gets loaded, the whole computer screeches to a snails pace -- check the logs, maybe they'll have some things :)

    Does your scheduled process launch a child, or do you do your work in the main process?

    Maybe all scheduled tasks are throttled, but children they launch aren't -- you could try launching a detached child ( Proc::Background )

    IIRC scheduled tasks used to be limited to ~60-90min runtime

    You could also try increasing the priority

    I doubt this is perl-specific, I think you'll have better luck on a MSDN/WMWare support forum :/

    Good luck

      I really appreciate the suggestions but will only be able to check one change per day as a maximum as the retrieved data is used during the day.

      Once I find a cause / solution, I will update the posting.
Re: Script slow only when run as scheduled tasks on Windows Server
by marto (Cardinal) on Nov 30, 2011 at 10:21 UTC

    I've experienced much weirdness on poorly configured virtual windows platforms. Our client had outsourced the installation and management of virtual platforms to a well known Outsourcing firm. The application in question was not written in Perl. When running on a normal windows server the application behaved reasonably, once migrated to a virtual platform it performance was unacceptable. At this point the resource utilisation was minimal. After much fruitless investigation on our part our client arranged for another virtual server (built in house, on the same blade platform). We couldn't replicate the problem on the new instance. The company responsible for the virtual servers couldn't track down the problem. Shortly after our client terminated their contract their, apparently because they didn't seem to have any idea what they were doing.

      Hello marto,

      I appreciate your suggestion to look into the machine but since the problem is apparently not related to the machine as such I have little hope here. The difference in performance is observed on a single virtualized machine in both cases.

      I am using the virtual machine and log onto it by remote desktop. Performance for the script is fine when started from the console. The same script on the very same machine (me still logged on) is extremely slow when running scheduled. I have full admin rights on the machine and there is no indication that resources are utilized in a noticeable way when the problem occurs.

        In our case we saw what you are seeing, no indication that the resources are being being taxed at all. I suspect our problem was based in the virtualisation setup, not the windows setup. However as you say, if performance is normal when run from the console this isn't your issue. Perhaps it would be wise to profile your program running from both the command line, and as a service. Comparing the output should narrow down where the performance bottle neck is occuring. See Devel::NYTProf. IIRC Windows has an optimisation setting, which allows you to choose 'Programs' or 'Background Services'. This may also be worth investigating. 'System properties' -> 'Advanced'->'Performance'.

Re: Script slow only when run as scheduled tasks on Windows Server
by GrandFather (Saint) on Nov 30, 2011 at 19:35 UTC

    Could it be that your scheduled task is running with different credentials than when you run from the console? That could result in failure handling sucking time in the scheduled task maybe?

    True laziness is hard work
      Thanks for the hint, but both the interactive session as well as the scheduled task are run using the same credentials.
        Hi Tabla, Regarding your post, do you have any solution. My executable is slower when run as scheduled task. Please hlep me ! Robin
Re: Script slow only when run as scheduled tasks on Windows Server
by Anonymous Monk on Nov 23, 2015 at 17:25 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://940786]
Approved by Ratazong
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-03-28 20:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found