Blog
Engineering
8
minutes

10 Tips To Reduce Your Deployment Time with Qovery

One of the most critical aspects of a developer's workflow is reducing deployment time. While Qovery does a lot of heavy lifting to make your deployments faster and more efficient, there are still ways to fine-tune the process on your end. This guide will help you optimize deployment time across three essential phases: Build, Deployment, and Runtime.
Romaric Philogène
CEO & Co-founder
Summary
Twitter icon
linkedin icon

Overview of the Deployment Pipeline

Understanding the deployment pipeline is the first step toward optimization.

Deployment pipeline - from Build to Run

The pipeline usually involves:

  1. Build: Compiling code and bundling dependencies into an executable package.
  2. Deployment: Transferring the package to the server and getting it ready for use.
  3. Run: The application is live and functional after the deployment is complete.

Tip: It's worth noting that the "Build" phase often consumes the most time in the entire deployment process. Being aware of this can help you prioritize your optimization efforts effectively.

Qovery Deployment Pipeline representation
Take a look here to dig deeper into how Qovery Deployment Pipeline works.

Diagnosing Deployment Time Drags

Before diving into optimizations, it's important to identify bottlenecks. The qovery environment deployment explain command can help you understand where your deployment spends most of its time, giving you actionable insights.

First, by listing your deployments

~ $ qovery environment deployment list --environment pr-234-preview-env
Id | Deployed At | Status | Duration
aa190093-9b25-4c7c-8cbf-2c59eec4929d-80 | 2023-09-03 06:59:06.720797 +0000 UTC | DEPLOYED | 18 minutes and 30 seconds
aa190093-9b25-4c7c-8cbf-2c59eec4929d-79 | 2023-09-02 19:59:06.016984 +0000 UTC | STOPPED | 9 minutes and 42 seconds
aa190093-9b25-4c7c-8cbf-2c59eec4929d-78 | 2023-09-02 08:35:51.976011 +0000 UTC | DEPLOYED | 2 minutes and 32 seconds
aa190093-9b25-4c7c-8cbf-2c59eec4929d-77 | 2023-09-02 06:59:05.095055 +0000 UTC | DEPLOYED | 14 minutes and 38 seconds
aa190093-9b25-4c7c-8cbf-2c59eec4929d-76 | 2023-09-01 19:59:04.156302 +0000 UTC | STOPPED | 9 minutes and 24 seconds
...

And then by getting the details of the deployment of our choice

~ $ qovery environment deployment explain --level step --id fae5c3aa-ae74-4560-b988-9f029a726533-1 --environment pr-234-preview-env
.
└── Environment: pr-234-preview-env [duration: 14 minutes and 58 seconds]
├── Stage 1: Databases [duration: 5 minutes and 31 seconds]
│ ├── Terraform RDS [duration: 4 minutes and 55 seconds]
│ │ ├── Step 1: Build [duration: 37 seconds]
│ │ └── Step 2: Deploy [duration: 4 minutes and 6 seconds]
│ ├── DB [duration: 1 minute and 13 seconds]
│ │ └── Step 1: Deploy [duration: 1 minute and 11 seconds]
│ ├── Redis [duration: 1 minute and 22 seconds]
│ │ └── Step 1: Deploy [duration: 1 minute and 22 seconds]
│ ├── My DB [duration: 1 minute and 22 seconds]
│ │ └── Step 1: Deploy [duration: 1 minute and 22 seconds]
│ └── SQS [duration: 3 minutes and 11 seconds]
│ ├── Step 1: Deploy [duration: 3 minutes and 11 seconds]
│ └── Step 2: Deployed [duration: 1 minute and 44 seconds]
├── Stage 2: Migration and Seed [duration: 1 minute and 18 seconds]
│ └── DB Seed Script [duration: 1 minute and 13 seconds]
│ ├── Step 1: Build [duration: 30 seconds]
│ └── Step 2: Deploy [duration: 21 seconds]
├── Stage 3: Backends [duration: 4 minutes and 42 seconds]
│ ├── DB Sync Cron [duration: 1 minute and 42 seconds]
│ │ ├── Step 1: Build [duration: 22 seconds]
│ │ └── Step 2: Deploy [duration: 10 seconds]
│ ├── Core Backend [duration: 4 minutes and 37 seconds]
│ │ ├── Step 1: Build [duration: 1 minute and 12 seconds]
│ │ ├── Step 2: Deploy [duration: 3 minutes and 18 seconds]
│ │ └── Step 3: Deployed [duration: 2 minutes and 21 seconds]
│ ├── Lambda [duration: 4 minutes and 23 seconds]
│ │ ├── Step 1: Build [duration: 1 minute and 2 seconds]
│ │ └── Step 2: Deploy [duration: 2 minutes and 46 seconds]
│ └── Backend [duration: 4 minutes and 37 seconds]
│ ├── Step 1: Build [duration: 1 minute and 15 seconds]
│ ├── Step 2: Deploy [duration: 3 minutes and 18 seconds]
│ └── Step 3: Deployed [duration: 1 minute and 52 seconds]
├── Stage 4: Gateways [duration: 53 seconds]
│ └── API Gateway [duration: 50 seconds]
│ ├── Step 1: Build [duration: 22 seconds]
│ ├── Step 2: Deploy [duration: 25 seconds]
│ └── Step 3: Deployed [duration: 9 seconds]
└── Stage 5: Frontends [duration: 2 minutes and 18 seconds]
├── Frontend [duration: 2 minutes and 13 seconds]
│ ├── Step 1: Build [duration: 1 minute and 16 seconds]
│ └── Step 2: Deploy [duration: 52 seconds]
└── Dashboard [duration: 0 seconds]
└── Step 1: Deploy [duration: 0 seconds]

In my context, the most expensive operation (almost 5 minutes..) is the Deploy from my Terraform RDS service inside my 1st stage Databases. In this example, I can't optimize the Terraform RDS since it takes time for AWS to spin up the resource. So independent from my end. However, I see a bunch of Build and Deploy steps that could be optimized.

If you remove the --level argument, you can see the details of each step. Which is verbose but perfect when you know what step you want to optimize first.

Here are the most important elements to improve your deployment time performance.

Recommendations

Build Phase: Reducing Build Time

Optimize Your Dockerfile

Optimizing your Dockerfile is like fine-tuning an engine for maximum performance. Start by using a lightweight base image — think of Alpine for Node.js applications. For instance:

FROM node:20-alpine

Multi-stage builds can further slim down your final image by keeping only what's necessary for runtime.

FROM node:20-alpine AS builder
WORKDIR /build
RUN --mount=type=ssh yarn install

FROM node:20-alpine
WORKDIR /app
COPY --from=builder /build/node_modules ./node_modules
...

Be strategic with layer caching. Cache your project’s dependencies, which seldom change, before the application code, ensuring faster builds.

Read more about Dockerfile optimization.

Use a Pre-built Container Image

The traditional way of deploying applications often includes building the entire stack from scratch. While this gives you control, it's often time-consuming. Utilizing a pre-built image can dramatically speed up your build time because the foundation is already laid out. Here's how.

Traditional Node.js Dockerfile:

# Build step
FROM node:14 AS build
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build

# Production image
FROM node:14
WORKDIR /app
COPY --from=build /app/dist /app
CMD ["npm", "start"]

Using a Pre-built Container Image:

Assume you have a pre-built image prebuilt-node-image that already contains your node_modules and other dependencies.

# Use prebuilt image
FROM prebuilt-node-image
WORKDIR /app
COPY . .
CMD ["npm", "start"]

The second approach eliminates the need to download and install Node packages each time, saving you precious minutes or even hours, depending on your application's complexity.

Utilize Build Tools Like Depot

Think of your build process as a production line. The efficiency of this line determines how fast your product — your application — gets to market. While Qovery provides highly optimized builders with 4 vCPUs and 8GB of RAM for each build and supports up to four builders running in parallel, there could be scenarios where you might need additional speed. This is where tools like Depot come in handy.

Depot Home Page - "The Fastest Place To Build Docker Images"

Depot caches your build artifacts, ensuring that repeated builds get faster over time. It's like adding another layer of efficiency to an already optimized assembly line. So, while Qovery's builders are robust and capable, you have the option to employ Depot for that extra dash of speed.

Frontend Optimization with Nx

When it comes to speeding up frontend builds, Nx is like your turbocharger. By using computation caching and parallel task execution, Nx significantly reduces build times, especially in monorepo settings where you have multiple frontend applications.

Read more about why the Qovery Frontend team uses Nx

Mono Repository Optimization

In a sprawling monorepo, it's inefficient to rebuild and redeploy every app for every minor change. Use Qovery deployment restrictions to act like a smart sensor, triggering builds only for the apps that have changed, thereby preventing unnecessary builds.

Deployment Phase: Quicker Deployments

Adequate CPU and RAM Allocation

Choosing the right amount of CPU and RAM for your app is like setting the correct tire pressure on a race car. Too low and you compromise speed; too high and you risk a blowout. Adjusting these settings appropriately ensures that your applications start faster and run smoother.

Avoid Building at Runtime for SSR Apps

Building at runtime, especially for Server-Side Rendering (SSR) apps, is like assembling furniture when you're trying to move into a new apartment — it's not the time nor the place. This approach increases latency and strains system resources. Always opt to pre-build your SSR applications to achieve faster and more stable deployments.

Aggressive Deployment Strategies like "Recreate"

Choosing the "Recreate" deployment strategy is akin to using a sledgehammer when you're in a rush; it's forceful but effective. This strategy stops the old application instances and immediately spins up the new ones, cutting the waiting time dramatically. However, use it cautiously; it's ideal for test environments but not recommended for production.

Recreate Deployment Strategy

Runtime Phase: Minimizing Startup Time

Efficient Health Checks

Configuring efficient health checks is like having a well-trained medical team at a sports event. They quickly assess the situation and make informed decisions, allowing for smooth and fast transitions. Proper health checks enable quicker deployments and offer better resilience against failures.

To learn more about Health Checks and Probes - read this article .

Continual Monitoring

Finally, never underestimate the power of constant vigilance. Monitoring your application is like having a seasoned coach who can spot even the tiniest inefficiencies and recommend immediate improvements. Consistent monitoring of system performance allows you to proactively optimize your settings, ensuring that future deployments are faster and more efficient.

Conclusion

Reducing deployment time is an ongoing process that involves both platform and user-side optimizations. While Qovery automates many tasks to make deployments faster, the strategies outlined above will help you make your pipeline even more efficient. So go ahead, implement these practices and shave off those valuable seconds or even minutes from your deployment time.

Happy Deploying!

Share on :
Twitter icon
linkedin icon
Ready to rethink the way you do DevOps?
Qovery is a DevOps automation platform that enables organizations to deliver faster and focus on creating great products.
Book a demo

Suggested articles

AWS
Deployment
 minutes
AWS App Runner Alternatives: Top 10 Choices for Effortless Container Deployment

AWS App Runner limits control and locks you into AWS. See the top 10 alternatives, including Qovery, to gain crucial customization, cost efficiency, and multi-cloud flexibility for containerized application deployment.

Mélanie Dallé
Senior Marketing Manager
Kubernetes
 minutes
Kubernetes Management: Best Practices & Tools for Managing Clusters and Optimizing Costs

Master Kubernetes management and cut costs with essential best practices and tools. Learn about security, reliability, autoscaling, GitOps, and FinOps to simplify cluster operations and optimize cloud spending.

Mélanie Dallé
Senior Marketing Manager
AWS
GCP
Azure
Cloud
Business
10
 minutes
10 Best AWS Elastic Beanstalk Alternatives

AWS Elastic Beanstalk is often rigid and slow. This guide details the top 10 Elastic Beanstalk alternatives—including Heroku, Azure App Service, and Qovery—comparing the pros, cons, and ideal use cases for achieving superior flexibility, faster deployments, and better cost control.

Morgan Perry
Co-founder
Kubernetes
DevOps
7
 minutes
Kubernetes Cloud Migration Strategy: Master the Shift, Skip the Disaster

Master your Kubernetes migration strategy with this expert guide. Learn the critical planning phases, mitigate major risks (data, security, dependencies), and see how Qovery simplifies automation and compliance for a fast, successful, and reliable transition.

Morgan Perry
Co-founder
SecurityAndCompliance
DevSecOps
 minutes
Qovery Achieves SOC 2 Type II Compliance

Qovery is officially SOC 2 Type II compliant with an Unqualified Opinion. Get the highest assurance of continuously verified security controls for enterprise-grade application deployments and simplify due diligence.

Pierre Mavro
CTO & Co-founder
Product
Observability
 minutes
Troubleshoot Faster with the New Log Search and Filtering in Qovery Observe

Following the launch of Qovery Observe, we’re progressively adding new capabilities to help you better monitor, debug, and understand your applications. Today, we’re excited to announce a major improvement to the Logs experience: you can now search and filter directly within your application logs.

Alessandro Carrano
Lead Product Manager
Platform Engineering
DevOps
Terraform
7
 minutes
Top 5 Crossplane Alternatives & Competitors

Go beyond Crossplane. Discover Qovery, the #1 DevOps automation tool, and 4 other IaC alternatives (Terraform, Pulumi) for simplified multi-cloud infrastructure management and deployment.

Morgan Perry
Co-founder
AWS
Platform Engineering
DevOps
9
 minutes
10 Best AWS ECS (Elastic Container Service) Alternatives

Compare the top 10 AWS ECS alternatives, including Qovery, Docker, EKS, and GKE. Find the best solution to simplify Kubernetes, automate DevOps, and achieve multi-cloud container deployment.

Morgan Perry
Co-founder

It’s time to rethink
the way you do DevOps

Say goodbye to DevOps overhead. Qovery makes infrastructure effortless, giving you full control without the trouble.