Case Study: Safary, from Coolify MVP to AWS ECS Fargate
How we took Iraqi food-delivery app Safary from a Coolify MVP to ECS Fargate, RDS and ElastiCache, with Datadog APM, cross-region backups and off-hours scaling.
Safary is a food-delivery platform in Iraq. Its site lists 500+ partner restaurants and 50K+ users, served through apps on Google Play and the App Store, plus a vendor app for restaurants and a dashboard for operations staff. All of them talk to one Laravel API.
We have worked with Safary since early 2025, first on getting the MVP live and then on moving production to AWS when the company started spending on growth. This is what we built, in the order we built it, and why.
“Pavora got us live fast, then moved us to AWS before our campaigns could test the old setup. The app hasn’t gone down since, and our database finally keeps up with our busiest hours. They work like part of our team.”
Bassel Bazzoun, Product Owner, Safary
Stage 1: an MVP on Coolify (February 2025)
At launch Safary needed to ship quickly, not to run a cloud platform. We containerised the Laravel API, the admin dashboard and the supporting apps and deployed them with Coolify on a single server.
That stage was about the basics: Docker healthchecks so broken containers are restarted, restart policies, and scheduled backups of Docker volumes. It was cheap, the developers could deploy without help, and it was the right choice for the traffic Safary had then.
Why the setup had to change
Things changed once Safary began running marketing campaigns. Campaign traffic is spiky and timed: a promotion goes out and thousands of people open the app at once, which is exactly when an outage costs the most. A single server meant one machine was a single point of failure, the database shared CPU and memory with the application, and scaling meant a bigger server and a maintenance window.
Stage 2: production API on AWS (January–February 2026)
We moved the production API used by the delivery apps to AWS in eu-central-1 (Frankfurt):
- Amazon ECS on Fargate runs the Laravel API as containers (nginx plus PHP-FPM with tuned OPcache), so there are no servers to patch.
- An Application Load Balancer sits in front of the tasks and health-checks each one before it receives traffic.
- Amazon RDS for MySQL replaced the database container, giving managed storage and automated backups.
- Amazon ElastiCache for Redis handles caching. The developers also added explicit cache invalidation when business settings change, so the apps never serve stale prices or settings.
- Amazon S3 stores user uploads and static assets, so the containers stay stateless and can be replaced at any time.
Disaster recovery. Automated backups are replicated to a second region, us-east-1, and kept for 30 days. We have tested restoring from them, so the recovery plan is proven rather than assumed. If Frankfurt had a serious regional outage, Safary could restore its data in another region instead of losing it.
Stage 3: Datadog, and a faster API
You can’t optimise what you can’t see, so before tuning anything we instrumented the API with Datadog APM (the PHP tracer with continuous profiling) and Database Monitoring, reporting to Datadog’s EU site.
The traces showed problems right away. The day after APM went live, Safary’s developers started removing N+1 queries, where an endpoint runs one database query per item in a list instead of one query for the whole list. The fixes covered some of the busiest endpoints in the customer app:
- category listings
- “most reviewed” food recommendations
- “order again”
- eager loading of related models across the app
Later, the vendor app got slow for restaurants with a long order history, and the same approach found the cause:
- the vendor profile counted orders by loading every order into memory; it now counts them in SQL
- the all-orders endpoint ran one extra query per order; it now eager-loads them
- order queries filtered through a nested relationship that MySQL could not index; they now filter on
restaurant_iddirectly, so the existing index is used - live order lists are now capped to recent orders, and older history stays available through a paginated endpoint, with no app update needed
Database Monitoring pointed to the other half of the problem: queries that scanned tables because the right index did not exist. We added indexes matched to the slow queries Datadog surfaced, then checked the query plans to confirm MySQL was using them.
We made the problems visible and worked with the developers on the fixes. The outcome:
- endpoint latency down 65%, from refactoring the code and adding the right indexes
- RDS CPU from constant spikes near 90% to under 20%, and it stays there through peak hours
Stage 4: deploy on merge
Every push to main runs a GitHub Actions workflow:
- builds the Docker image with a registry layer cache, so unchanged layers are not rebuilt
- pushes it to Amazon ECR, tagged with the commit SHA, so any running version can be traced back to the exact code
- registers a new ECS task definition revision with that image
- rolls the ECS service onto it behind the load balancer
- posts a “deployed” message to the team’s Telegram channel
Deploys are serialised (one at a time, never cancelled midway), and third-party actions are pinned to commit SHAs rather than moving tags.
Stage 5: pay less at night
A food-delivery API is busy at lunch and dinner and almost idle in the early hours. Paying for peak capacity around the clock made no sense, so we wrote a small scheduler with AWS SAM:
- an EventBridge schedule runs a Python Lambda function at 01:00 Iraq time
- the function clones the current task definition with half the CPU and memory (8 vCPU / 20 GB → 4 vCPU / 10 GB) and moves the service onto it
- at 08:30 the same function scales it back up
- every change posts to Telegram with the new size and task definition revision
The overnight schedule cut the API service’s Fargate bill by about 16%, without touching the application.
What stayed on Coolify, and why
Not everything has to go to AWS. Safary’s internal tools still run on Coolify: a live order-monitoring dashboard for the call centre, a review app and a QR-menu service. They have a small, known set of users, and moving them would add cost without reducing much risk.
Instead of opening ports on that server, we publish them through Cloudflare Tunnel, with Cloudflare WAF in front. The server makes outbound connections only. Nothing on it accepts inbound traffic from the internet, so there is no public IP to scan and no firewall rule to get wrong.
Results
- 100% uptime since the move to AWS, in line with the agreed SLA, including through campaign peaks
- 65% lower endpoint latency after the code and index work
- RDS CPU under 20%, down from constant spikes near 90%
- every merge to
maindeploys automatically, with a chat notification - backups replicated to a second AWS region and kept for 30 days, with tested restores
- about 16% off the API’s Fargate bill from off-hours scaling
- internal tools stay cheap on Coolify, with no inbound exposure
Is this you?
The path that worked for Safary is a common one: ship the MVP on something simple, then move only the revenue-critical part to managed AWS services once the business depends on it. If you are at that point, our DevOps consulting and cloud cost optimization work starts with the same question we asked here: what actually needs to move?
Frequently asked questions
When should a startup move from Coolify to AWS?
Coolify on a single server is a sensible way to ship an MVP: it is cheap, quick to set up and simple to run. The time to move is when downtime starts to cost real money and one server becomes the risk, for example before paid campaigns send traffic spikes you cannot predict. At that point you want managed databases with automated backups, more than one application task behind a load balancer, and deployments that do not touch the server by hand.
Do you have to move everything to AWS at once?
No. Safary moved only the customer-facing production API. Internal tools with a small, known set of users stayed on Coolify, published through Cloudflare Tunnel so the server has no open inbound ports. That kept the migration small and the AWS bill focused on the workload that earns revenue.
How do you cut ECS Fargate costs outside business hours?
An EventBridge schedule triggers a Lambda function that registers a smaller task definition revision and updates the service. Safary's API drops from 8 vCPU and 20 GB to 4 vCPU and 10 GB overnight, then scales back up before the morning rush. Every change posts a notification to the team's chat, so nobody is surprised by it.