Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combine json files on server and optimize performance for chart loading #36

Open
elcojacobs opened this issue Feb 15, 2014 · 9 comments

Comments

@elcojacobs
Copy link
Member

All json files for a beer are downloaded separately and combined in javascript.
Combining them on the server might be faster, because it does not require lots of ajax requests.

Brian got started in the feature branch optimize-beer-data-loading.

I fixed some errors in the resulting json and the branch now works correctly. (elcojacobs@11b3628).

I am now profiling the file with xdebug and webgrind.
json_decode and json_encode are the heaviest functions. The files that are loaded are already json, so I think we can avoid decoding and encoding.

image

@elcojacobs
Copy link
Member Author

I replaced the json_decode and json_encode with string parsing:
df03c83

The time is down from 614 to 70ms on wamp:
image

@elcojacobs
Copy link
Member Author

I now also removed the datatable and the dependencies that came with it (google jsapi).
The data is now parsed to Dygraph native array format. More testing is needed, and I would like to get rid of the use of eval()

deaef68

@elcojacobs
Copy link
Member Author

The annotations should be passed to the chart separately, I am working on that part.

@elcojacobs
Copy link
Member Author

Annotations now work again 😃
Please take a look at the code, I am sure it can be improved.
63be43b

@wfowlks
Copy link

wfowlks commented Oct 23, 2014

I was running pagespeed because I noticed that when a beer was going for several days, there was great latency when loading the graph and on the page. The Ajax is not asynchronous so it prevents me from changing the temperature before the graph is loaded which lately has been 6+ seconds just for get_beer_data.php, I will take a stab at this and see if I can help at all.

Running Google's PageSpeed plugin for chrome, Google suggested minifying the CSS files as well as the javascript files. Might it be possible to minify for production but leave the full css for development?

@jhferris
Copy link

wfowlks,

minifying the js and css are highly unlikely to appreciably improve your page load times (from 6 seconds, anyway)

I suspect the core problem is that the get_beer_data.php bit takes a while on the server because of the way it loads/transforms the data.

@wfowlks
Copy link

wfowlks commented Oct 23, 2014

jhferris,

Minification gave me a 1/2 second improvement on load times on my desktop and 1 second for mobile. But I do concur that the main latency is the data transformation.

Do you think that utilizing SQLlite instead of having a json log file for each day might be an improvement.
THe main Pagespeed suggestion was to utilize the browser cache.

@elcojacobs
Copy link
Member Author

For next gen, we think influxdb might be a good database to store the timeseries data. The chart could then query for a subset of the data and get more datapoints when the user zooms in.

After getting the data in influxdb, grafana might be a nice configurable dashboard to display charts.

@wfowlks
Copy link

wfowlks commented Oct 24, 2014

I spent some time last night trying to install influxdb on my pi, however it was pretty painful and I was unsuccessful. I tried using the prebuilt binaries, as well as building from scratch. If you are successful can you let me know what you did, because I'd like to try it out and see if there are any performance improvements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants