Categories
apache flask javascript postgresql python

Serving out user customized scripts in high volume

We currently have a script which is served out via a web server (Flask through Apache WSGI).

This is a user customizable Javascript file which includes some common logic, and some user customizable parameters which differ from user-to-user.

The current method to serve it out seems very inefficient to me, and that’s to store each users’ config in a local database and append on the common logic code before sending it out. For example:

var user_config = {...};
// ====== separation ======
var logic = (function() {
// Consume config data here
});

The config is done with users logging into our website and customizing a number of features they want, but the config is basically a very large JSON.

The reason this was done originally was to make the client code as simple as possible. They’d simply include a script tag on their website with their ID:

<script src="http://path.to.script?id=ABC></script>

The problem I’m finding now is, I’m trying to modify the originally developed method to better handle a high-load, as it seems to be struggling at the moment.

What would be the way to serve out these per-user customized scripts to best reduce load on our server(s), while maybe taking advantage of some caching or other load reducing features.