Services

Ok, we've learned about how Nitric helps with infrastructure, now let's dive where you run your code: Services.

In Nitric, a service is an isolated unit of computing, typically Nitric builds and deploys each services as its own Docker container. Your project might contain a single service (e.g. a monolithic web application), a few services (e.g. a web application, a background worker, and a scheduled task) or many services (e.g. a microservices architecture).

Service Categories

There are currently two categories of services in Nitric:

  • Standard Services: These are services that are designed to handle incoming requests, such as web applications, APIs, and websockets. Standard services are the entrypoint for your application's logic.
  • Batch Services: These are services that are designed to process large amounts of data in a single operation. They are ideal for tasks like data processing, running/training AI models, image resizing, or running scheduled jobs. With access to resources like GPUs and large amounts of memory.

Defining Services

Services are defined in your project's nitric.yaml file. Each service has a name, a type (groups of services with shared resource requirements), and a path to the service's code.

See the Project Configuration page for more information on defining services in your project.

If you started with a project template, you'll already have a nitric.yaml file with services defined.

When you define a service in your nitric.yaml file, Nitric automatically takes care of turning it into a container. Each service can then run independently, allowing your app to scale and manage different workloads efficiently. Services can interact with resources like databases, queues, and buckets, which are defined separately but linked at runtime by Nitric.

You can also specify your own Dockerfile template for some/all of your services, allowing you to customize the build process for your services.

See the Custom Containers and Project Configuration pages for more information about how to customize the way Nitric builds your services.

Last updated on Oct 16, 2024