Should graph data be generated in the back end or front end? Should graph data be generated in the back end or front end? php php

Should graph data be generated in the back end or front end?


To add more to your list you could take the following into account.

  • Serializing and manipulating data in the back-end uses more RAM, since all your data is first loaded into memory.
  • To keep your back-end standardized and structured, you should only be accessing resources through your REST API. Manipulating data on such a huge scale has no real value for your API.
  • Using front-end to manipulate the data will use more native resources, and therefore save your server heaps of processing and ram on creating the "graph" data. The graph will render at native speed, and not hang on the server to first construct it.
  • Unless you're writing applications that are constantly under threat of being hijacked/hacked (Like a bank). You don't really need to worry about someone else writing their own versions of your graphs. It takes too much time, and isn't exactly something you would need to consider a viable threat to the business/application.

Hope I helped a bit.
PS

I'd recommend using the back-end REST API as only a Database / resource exposure, and not have much application logic.

Your JS app should be handling all the data manipulation to structure whichever information it's trying to convey.


  • expensive computations or any sort of computations for graph should happen on the back-end. Even if the back-end ends up consuming more memory or cpu, you can control that by scaling/autoscaling your back-end servers based on CPU, Response time , Memory, etc..
  • If front-end does the computations and lets assume it has years and months of data points, processing happens on the client's browser app for which your app has no control too. This is especially the scenario for those who play multiple browser tabs or apps at the same time.
  • Debugging or pin pointing the issue is easier if all computations are done on the back-end.


If the back end is capable of doing the conversion, then ideally the client could have the option of getting raw or formatted output. Best of both worlds?