Server Roles Reference
This guide provides detailed information about the how server roles can be used in Blossom and how to use them with your application deployment.
Infrastructure Roles
These roles are for servers that handle infrastructure tasks and don’t require application code deployment:
- load balancer: Routes traffic to your application servers
- build: Dedicated server for building Docker images
- db/database: Database server (requires special consideration - see below)
- service: Generic infrastructure service
When a server has only infrastructure roles, your application code will not be deployed to it.
Application Roles
Application roles are dynamic and map directly to processes defined in your Procfile. Any role that isn’t an infrastructure role is considered an application role and will receive application code deployment.
Common examples include:
- web: Runs your web application processes
- worker: Handles background jobs
- clock: Runs scheduled tasks
The system is flexible - you can use any role name that matches a process type in your Procfile.
Role Combinations
You can combine roles to create different server configurations:
-
Dedicated Role Servers
- Single role per server (e.g., dedicated web server)
- Provides isolation and specialized resource allocation
- Recommended for high-traffic applications
-
Multi-Role Servers
- Multiple roles on one server (e.g., web + worker)
- More cost-effective for smaller applications
- Good for development and staging environments
Recommendations
-
Database Servers (Important)
- You should use dedicated servers for databases
- Databases are stateful - losing a database server means losing data
- It’s not recommended to combine database roles with other roles
- Consider using managed database services in production
- Regular backups are essential
-
Application Servers
- Application servers (web, worker, etc.) are stateless
- Can be safely replaced or recreated if needed
- Feel free to combine roles for cost optimization
- Separate roles as your application grows
-
Build Server
- Use a dedicated build server to prevent Docker builds from impacting app performance
- Build operations are CPU-intensive and can consume significant disk space
-
Load Balancer
- Consider a dedicated load balancer for production environments
- Ensures reliable traffic distribution
Role Assignment Example
Here’s how roles map to processes in your application. For example, if your Procfile has:
web: bundle exec puma -C config/puma.rb --port $PORT
worker: bundle exec rake solid_queue:start
clock: bundle exec clockwork config/clock.rb
- A server with the
web
role will run the Puma web server - A server with the
worker
role will run the background job processor - A server with the
clock
role will run the scheduled tasks - You can create servers with multiple roles (e.g.,
web,worker
) to run multiple processes
Remember, you can define any process type in your Procfile and create matching server roles. The role name simply needs to match the process name in your Procfile. This flexibility allows you to organize your application processes however makes sense for your specific needs.