server side pre-generation and caching of charts

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
hongping
Posts: 14
Joined: Thu Jul 29, 2004 1:32 am

server side pre-generation and caching of charts

Post by hongping » Mon Aug 16, 2004 4:48 pm

Hi,

I am currently developing a web application that displays statistics of computers such as cpu and memory usage. The web application runs on a server, and provides stats about many other computers by getting the information from a database. Users of the web app can choose to view the stats at different interval ranges, and stats from only specified computers.

For example, stats from past hour with a sample taken every 1 min; past day with a sample every 5 mins; past week with a sample every 1 hour and so on.

My first design model is a straight forward one. For each individual request, the server retrieves all the data from the database, creates a new jfreechart using the data and renders the chart as an image to be sent to the user.

My second approach was simply to cache the data points of the graph currently being viewed in the session on the first request, and retrieve only the latest stats and updating cached copy. However, this requires checking if the user is viewing the same graph as the previous request. And if not, the cached is cleared and the whole thing starts over again.

I was thinking of scalability issues with these approaches. I am wondering if there are any tools or standards for such a problem.

1. If a thousand viewers are looking at the same graph, should it be pre-generated and available to all?

A suggestion might be to have a thread pre-generate the graphs at a regular interval.

2. However, if the webapp is getting stats for one thousand computers and needs to pre-generate all the graphs, wouldn't a lot of graphs be generated but only a small subset of the graphs be actually used?


I would appreciate any guidelines or pointers, to any best practices or tools for dealing with this problem.

Thanks!

Locked