Web unit and computing unit

Posted May 1, 2020 434 views

So I managed to get my website working on a droplet (docker image with nginx, gunicorn, django). The website is still under development (I’m new to web development). The website is intended to be an interface for the user to interact with an finite element solver I wrote in C++. Each time the user hits the solve button, the C++ must be invoked to solve the problem. Now, solving such a problem can be time consuming as well as computationally expensive. So, I guess it wouldn’t be wise to host both the web and the app on one single droplet, since the website wouldn’t run smoothly anymore (is that correct?). So I thought to get another droplet which would take care of the computation part. Is this the right way of thinking? And if so, can I pass the input of the user from the web droplet to the computing droplet?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

Hi there @michielfenaux,

I like the approach of keeping the different services separately, it’s kind of leaning to the whole microservices architecture. That way the services (your frontend and the computation service) would be loosely coupled and independently deployable, so in case that the computation service goes down due to overload, your website would still remain running.

Actually this would be your approach even if you go for Kubernetes for example, you would have your different services, packaged into Docker images, and deployed as separate services to the cluster.

Of course, you could always have all of the components on a single Droplet in the beginning and later scale with a few Droplets.

Passing the input from your website to the backend service which would be doing the computation could be done through an API. For example, on the backend service, you could expose an endpoint that expects a certain payload, and then you could just hit that API endpoint with a POST request including the necessary parameters from your frontend.

Hope that this helps!

Thanks @bobbyiliev, this was helpful to understand the big picture (not familiar with kubernetes yet).

As I understand it, in this situation, my web on one droplet is considered as a frontend and my other droplet with the C++ app would be the backend. I would then send information forth and back by means of requests. Is that correct?

  • Hi there @mfnx,

    Yes indeed, this sounds correct.

    Here’s a rough diagram of what the flow would look like:

    Frontend server API call to backend server

    The flow could look something like this:

    • People would be able to browse your website as normal
    • Only when your users need to use the computation part the frontend server could make an API request to the backend server
    • In the payload of the request, you would have the necessary information which is required for the computation to be executed
    • The backend would do the computation and send a response back to the frontend with the result of the computation

    Of course, this is just a rough idea of how this could work.

    Hope that it helps!

    • Ok, thanks a lot to make this clear and save me time. I’ll check how to make those API requests between droplets.
      BBtw: sorry for posting the above as an answer to my initial question. I see now this is incorrect.