DEV Community

Rishabh Bisht for MongoDB

Posted on

Building With Symfony: Scaling Surfshark’s Backend

Curious about how leading companies leverage Symfony to build and scale their platforms? In the new Building With Symfony article series, we dive into the tech stacks of innovative organizations and share first-hand insights from their engineering teams. Discover the key tools, architecture choices, and best practices that help them deliver reliable, high-performance applications at scale.

This article was contributed by Vaidas Lažauskas, the Head of Backend Engineering at Surfshark.

Launched in 2018, Surfshark is a prominent cybersecurity company that provides a range of online privacy and security solutions. Best known for its VPN service, Surfshark has a team of over 500 employees spread globally and has been honored with more than 30 international awards. The company's mission is to build the most beloved security products for everyone. Surfshark has over 35 million application downloads, supported by more than 3,200 servers in 100 countries.

Architectural overview

Surfshark processes over 5,000 API requests per second! It leverages a robust backend that utilizes the Symfony framework with MongoDB as its primary database. Their system is designed to handle operations at a massive scale—the largest MongoDB collection has over 45 million documents! The back end is fully structured around microservices architecture. In fact, Surfshark has never used a monolith; from the very beginning, all services have been built as microservices and all the infrastructure is deployed on AWS.

The Symfony + MongoDB stack

Surfshark’s backend is built with PHP and the Symfony framework. Since the very beginning (over seven years ago), they've integrated MongoDB using Doctrine ODM, making full use of its query builder for application development. All new services are built on this stack, with plans underway to retire MySQL entirely. The Surfshark team has also contributed pull requests to Doctrine ODM in the past and actively supports the Symfony community. Surfshark is committed to staying up-to-date with their dependencies, upgrading major versions annually and keeping libraries fresh every week. They've recently migrated from MongoDB 7 to 8, with a smooth, zero-downtime upgrade that required no application-level changes—a testament to the robustness of their integration and the power of MongoDB Atlas.

“We use Compass. It’s a really great tool for entry level developers for index management and analyzing collections.”

Development at Surfshark is fully Dockerized using Docker Compose, with Mutagen syncing local files into the Docker environment for a seamless workflow. Developers predominantly use PHPStorm and work with MongoDB running in Docker containers during local development. For database management and analytics, the team enjoys a variety of tools:

  • MongoDB Compass: Excellent for entry-level developers and for index/collection analytics
  • MongoDB Shell: Preferred for flexible scripting and rapid prototyping

Overall thoughts on working with Symfony and MongoDB

When Vaidas joined Surfshark, the backend relied heavily on MySQL—with multiple services built on top of it. However, as the platform scaled and handled thousands of requests per second, it experienced interruptions and errors under load. To solve this, Vaidas introduced MongoDB, and all new services immediately started using it as the primary database. Today, about 90% of Surfshark’s data is housed in MongoDB.

“The main thing every new developer notices is that there is no migration schema madness. We still have MySQL for some legacy services, so we need to run migrations, using Percona toolkit, whenever we have to add a new field to the schema. We get thousands of requests per second. Just renaming the table will cause us to lose user requests because of errors that might appear while migrating. The new devs are amazed that there is no fixed schema with MongoDB. You make a change and just push to production.”

They also appreciate that schema and index changes can be performed without interrupting service, which is crucial for a platform serving thousands of requests per second.

“Creating an index is also seamless. You pass the new index and it just works without any interruption.”

Expiring data like auth tokens is easy and robust. They found MongoDB’s TTL handling superior to other solutions they have used, as the data is truly physically removed on schedule.

“TTL index is also a great feature. Many other databases have this feature but it works so much better in MongoDB because the data is always physically deleted right away.”

Surfshark’s story shows how Symfony and MongoDB can work together to power a fast-growing, reliable backend. By focusing on flexibility, easy scaling, and solid developer tools, they’ve built a system ready for millions of users. If you’d like to learn more about modern backend architecture or see how other companies use Symfony in production, stay tuned for the next articles in this series. Curious about integrating Symfony and MongoDB in your own projects? Check out our Symfony MongoDB integration to get started!

Top comments (0)