Question

Function(s) / worker(s) / service, what to pick for my needs?

Hi there! Front-end developer here who’s been diving into more exciting stuff, but I’m running into some bottlenecks and I’m unsure what to pick.

Been working on a nodejs/mongodb/graphql/react app (in web3 space). I’m currently testing the app with a service and a static front-end within the app platform.

The front-end users can start a process to index their wallet, this process takes between 10 and 120 seconds, let’s say 50 seconds on average. I want to keep the user updated during the process through polling (somehow can’t get web sockets to work, separate port issue? Not sure). I’m not expecting a gigantic amount of traffic, but I need 1 external API (which is rate limited) to always work.

So I can imagine a queuing system of some sort and delegate parts of the code (the indexing function) to a separate function/worker or service.

Although I’ve managed to set up a droplet and did get my app running there, I prefer to stay serverless within the app platform as much as possible for now.

Could probably build a simple queue with a database increment/decrement. But I still like to know where to place the indexing function (function/worker/service) to also optimize that part. Any tips/ideas are welcome.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Jon Friesen
DigitalOcean Employee
DigitalOcean Employee badge
January 31, 2023

Hey @BubblyDarkCyanFish!

Welcome!

It sounds like your app could use either an App Platform services or functions, or even a combination of both!

Websockets in App Platform run on the same port as the service and are a connection upgrade that happens within your code. Here’s a NodeJS tutorial that might help you get that working.

I’m not super familiar with the web3 space so bear with me. If your queue is holding individual user workflows you toss them in your database and then process groups at a time in a worker or service though you could also fan out to functions and run all of your user workloads at the same time because functions can run a single job and do as many as you need in parallel.

My advice to you would be to start simple and then optimize for load/distribution as needed. That might mean a static site, service, and database with workers, functions, etc coming in the future.

Jon Friesen
DigitalOcean Employee
DigitalOcean Employee badge
January 31, 2023

Hey @BubblyDarkCyanFish!

Welcome!

It sounds like your app could use either an App Platform services or functions, or even a combination of both!

Websockets in App Platform run on the same port as the service and are a connection upgrade that happens within your code. Here’s a NodeJS tutorial that might help you get that working.

I’m not super familiar with the web3 space so bear with me. If your queue is holding individual user workflows you toss them in your database and then process groups at a time in a worker or service though you could also fan out to functions and run all of your user workloads at the same time because functions can run a single job and do as many as you need in parallel.

My advice to you would be to start simple and then optimize for load/distribution as needed. That might mean a static site, service, and database with workers, functions, etc coming in the future.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up