Alright, so this update has been a long time in coming. I have been slowly chugging away at this, but the problem that I could not draw two CAD drawings at the same time really threw a wrench into my plans of having this available as a web application.
I am happy to announce that I have solved the problem and I now have a working application which can handle drawing more than one CAD at a time.
I will attach a flow diagram at the end, but here is the basic idea:
- On my server I have a Tornado application which acts as my webserver. It basically hosts the website.
- When new drawing requests come in, the Tornado server will automatically spin up a new LXC container (which is basically running the exact same Tornado application) as a worker for that request and the parent server directs the LXC worker to actually draw the CAD.
- When the CAD is finished being drawn, the LXC worker will upload all the files into an AWS S3 bucket and will return to the parent server the metadata and where to find the files in S3.
- When the client requests to download the CAD files, the request is sent directly to S3 and the files are retrieved from S3 without ever actually hitting my server.
- In addition, if subsequent requests are made for the exact same layout (including holes, padding, etc, etc...) the server will see that the CAD has already been drawn, and it will return the request directly referencing the existing S3 files for that drawing. For a cache hit, the two have to be identical, so even if legends on the layout changes (which does not affect the resulting CAD), it will miss the cache and redraw from scratch.
- Once an LXC worker has finished doing its work, it will automatically be destroyed.
That is basically it. Here is a graphic to illustrate what I specified above...