Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: Perl modules (was: Re: Begginer's question: ...)

by predrag (Scribe)
on Jan 20, 2017 at 09:20 UTC ( [id://1179981]=note: print w/replies, xml ) Need Help??


in reply to Re: Perl modules (was: Re: Begginer's question: ...)
in thread Begginer's question: If loops one after the other. Is that code correct?

Hauke D I was thinking again about your post and hope that it is not a mistake to reply to your comments, even if we maybe go a little out of the topic.

Traditional CGI scripts would get re-executed on every request to the web server, so start-up times on CGI scripts would make a difference, especially if they get many requests per minute. There are however more modern web servers in which the scripts keep running between requests, in which case the start-up times do not matter. Of course, if this is just a small web page on which you don't expect many requests, start-up times of the scripts may not matter much at all. Otherwise, it would be wise to consider ways to optimize, such as using one of the more modern implementations that keep the scripts running. Another approach might be to not re-generate the charts on every request, instead keeping them cached and only re-generating them when necessary, such as based on an interval or when the data changes.

During last year, my website had about 400-1000 daily visits and with the new design and much of new content I expect more visits in the future. So, I should have all that in mind while working on my CGI scripts.

I would like to realize web monitoring on my website, with data about bee hive weight, weather etc. It would be ideal if some or all of these data are presented visually, so this is why I asked a question about modules for plotting in Perl.

From your comment I see that maybe your last suggestion is most appropriate for me ( not re-generate the charts on every request) because in the simpler version, data would changes probably two times a day. Pages with these data will be very attractive to visitors, so it can significantly increase web traffic.

Anyway, when I have some results, I will ask perlmonks for comments

regards

predrag

  • Comment on Re^2: Perl modules (was: Re: Begginer's question: ...)

Replies are listed 'Best First'.
Re^3: Perl modules (was: Re: Begginer's question: ...)
by haukex (Archbishop) on Jan 22, 2017 at 10:32 UTC

    Hi predrag,

    data would changes probably two times a day

    One way to do this would be with a cron job calling a Perl script that generates the charts twice a day and saves them as image files. Then, the web server would only have to serve up static files, without the need of calling a CGI script to get the images.

    Regards,
    -- Hauke D

      One way to do this would be with a cron job calling a Perl script that generates the charts twice a day and saves them as image files. Then, the web server would only have to serve up static files, without the need of calling a CGI script to get the images.

      Hauke D, thank you for that new suggestion, I didn't think that way.

      So, all these images with that chart should be saved under the same file name. And that image file will be inserted in html page. When data change, new image will be saved and automatically will become visible in html page after page refreshing or a new visiting? Did I understood well?

      It is really extremely simple. The only con is that it can't show data in a table. But really excellent solution and I can use it for that project or something else.

        Hi predrag,

        So, all these images with that chart should be saved under the same file name. And that image file will be inserted in html page. When data change, new image will be saved and automatically will become visible in html page after page refreshing or a new visiting? Did I understood well?

        Yes, exactly!

        The only con is that it can't show data in a table.

        The same principle can be applied to HTML pages as well: In the Perl script that generates the charts, you could also generate an HTML page that is saved to the web server directory that includes the data in a table as well. (This Perl script that is run at a fixed interval, in this case twice a day, can generate as many different files as it likes.)

        Regards,
        -- Hauke D

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (7)
As of 2024-04-19 13:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found