Learning paths / Deploy on ComputeSphere / How ComputeSphere is organised

Service types: web service, background worker, cron job, static site

Reading · 6 min · Module 2, lesson 2 of 417 min left in this module

Module 2 · How ComputeSphere is organisedLesson 2 of 4

Goal: Choose the right service type for each part of an application.

Key idea

A service's type decides what it gets: a public URL or not, and whether it runs all the time, on a schedule, or not at all. Pick the type from how the part is used.

Web service

For anything that answers HTTP requests: a website, an API, a server-rendered app. If people or programs call it over HTTP, it's a web service.

  • It gets a public HTTPS URL, and can have custom domains.
  • You give it the port your app listens on, the numbered door inside the container where requests arrive.
  • It can have a health check: an address in your app that new versions must answer before they get traffic.

hello-web, from Module 1, is a web service.

Background worker

For work away from any request: processing uploads, sending emails, taking jobs off a queue (a waiting list of jobs that one part adds to and another works through).

It runs all the time, like a web service, but has no URL and nothing on the internet can reach it.

A common pattern: the web service puts a job on a queue and answers the user straight away; the worker picks it up and does the slow part.

Cron job

For work that runs at set times and then stops: a nightly report, an hourly cleanup.

You give it a schedule in cron format. 0 2 * * * means “at minute 0 of hour 2, every day”: 2 a.m. daily. Each run has its own log, so you can see what happened at 2 a.m. last Tuesday.

Static site

For sites that are only files once built: documentation, a landing page, a single-page app with no server of its own.

It's built from a Git repository and served from ComputeSphere's edge, the servers that answer web requests, so no spherelet runs for it. It gets a URL and custom domains like a web service.

Check yourself

Part of your app emails every customer a summary at 7 a.m. each Monday. Which type?