← Back to list

How Celery and GitLab CI/CD can make ML systems more scalable, reproducible, and production-ready.

Machine learning systems are not only about training models. In real-world applications, the larger challenge is often ensuring that…

Haocheng Lin · 2026-05-09 17:38 · 1 claps · 2.9 min read
#machine-learning #continuous-integration #ml-workflow #dockerized #mlops-architecture
Open on Medium ↗
Wiki topics: OPS · LLMOps & Inference ML · Machine Learning EDU · Education & Learning ☁️ · DevOps & Cloud 🔓 · Open Source 🏛️ · Architecture

How Celery and GitLab CI/CD can make ML systems more scalable, reproducible, and production-ready.

Machine learning systems are not only about training models. In real-world applications, the larger challenge is often ensuring that models, datasets, evaluation scripts, and deployment workflows remain reliable as the system changes. A small code update, a new dataset version, or a modified preprocessing function can silently affect model performance.

In this project, I built an automated ML testing and validation system using Celery and GitLab CI/CD inside a Dockerised Django application. The goal was to make ML validation more scalable, reproducible, and less dependent on manual execution.

The project was designed as a workflow for continuous machine learning validation. When a model, dataset, or pipeline component changed, the system could run automated checks to evaluate whether the ML workflow still behaved as expected.

At a high level, the architecture separated two responsibilities:

  1. Celery handled asynchronous ML workflow execution, allowing long-running validation jobs to run in the background.
  2. GitLab CI/CD handled automated testing, validation, and deployment checks whenever the codebase or model pipeline changed.

ML validation jobs can be slow and resource-intensive. Tasks such as dataset preprocessing, model evaluation, metric calculation, and report generation should not block the main web application.

To solve this, I used Celery as an asynchronous task queue. Instead of running validation jobs directly inside the Django request-response cycle, the application submitted jobs to a Celery queue. Celery workers then picked up these jobs and executed them independently in the background.

The workflow looked like this:

  1. A user or system event triggered an ML validation job.
  2. Django created a Celery task.
  3. The task was added to the queue.
  4. A Celery worker executed the validation pipeline.
  5. Results such as accuracy, loss, and evaluation metrics were saved.
  6. The application could later display the job status and results.

This made the application more responsive and allowed ML validation to become a repeatable, monitorable workflow rather than a manual script.

While Celery handled runtime workflow execution, GitLab CI/CD handled the development and integration side of the project. Every time the codebase changed, the CI/CD pipeline could automatically run quality checks before the change was merged or deployed. This helped reduce the risk of breaking the ML validation workflow through small changes in preprocessing logic, evaluation code, dependencies, or application configuration.

A typical GitLab CI/CD pipeline could include:

  • installing dependencies
  • running unit tests
  • running integration tests
  • validating data-processing functions
  • executing a lightweight model-evaluation job
  • checking that the Dockerised application built successfully

In this sense, GitLab CI/CD acted as a gatekeeper for reliability. It ensured that changes were tested automatically before they entered the main workflow.

The key design principle was to separate runtime orchestration from development-time validation.

Celery was responsible for running long-running ML jobs asynchronously after the application was active. GitLab CI/CD was responsible for checking that the code, tests, and workflow components were valid before changes were integrated.

Together, they created a stronger MLOps workflow: Celery made the system scalable at runtime, while GitLab CI/CD made the system safer to change during development. For example, if a new model version or dataset update was introduced, GitLab CI/CD could first run automated tests to confirm that the pipeline still worked. Once the change passed validation and was deployed, Celery could then execute the actual ML validation jobs asynchronously, loading data, running evaluation, calculating metrics, and storing results.

The application was built around a Django backend, with Celery workers used for asynchronous task execution. Django acted as the main application layer, while Celery handled background ML jobs. GitLab CI/CD provided automated validation whenever the repository changed, running tests and build checks to ensure the workflow remained reliable. The project was also Dockerised, making the system easier to reproduce across environments.


메타데이터
post_id
c6ab2b6ed92a
slug
how-celery-and-gitlab-ci-cd-can-make-ml-systems-more-scalable-reproducible-and-production-ready-c6ab2b6ed92a
url
https://medium.com/@haochenglin/how-celery-and-gitlab-ci-cd-can-make-ml-systems-more-scalable-reproducible-and-production-ready-c6ab2b6ed92a
canonical_url
https://medium.com/@haochenglin/how-celery-and-gitlab-ci-cd-can-make-ml-systems-more-scalable-reproducible-and-production-ready-c6ab2b6ed92a
author_url
https://medium.com/@haochenglin
status
ok
fetched_at
2026-08-08 04:24:00