SNCF is the national rail operator in France. Its mission is to make travel simpler while delivering seamless, sustainable passenger and freight services. One way it achieves this is with SNCF Connect, an app designed and developed by an in-house organization called SNCF Connect & Tech. A third of France’s population use the app to search for routes, book tickets, and get the latest information on trains, buses, and other modes of public transport.
This app is critical to SNCF’s business. More than 550,000 tickets are sold through the app every day, and volumes are growing fast. Between 2022 and 2024, annual sales soared from 190 million to 209 million. It also needs to scale up to handle seasonal peaks such as the Christmas sale period, which starts in October.
“Christmas sales are the biggest commercial event of the year for SNCF Connect,” said Vincent Liboutet. “It gives passengers the opportunity to plan their trips in advance. They can browse the timetable, find the best ticket prices, and we add new destinations to make sure as many people as possible can use public transport during the holidays.”
In 2023, the database behind SNCF Connect was processing 1 million connections per minute, up from 300,000 connections per minute the year before. Spring ticket sales, which start at the end of January, are another busy period – 1.3 million tickets were sold in just one day, a 29% increase compared to 2022.
Making the app more scalable and easier to manage with MongoDB Atlas.
As SNCF Connect grew in popularity, the company’s database admins began to struggle with maintenance and scalability challenges. The original database design was also unsuitable for integrating new business functions, which limited its ability to meet changing passenger expectations.
In 2022, the company decided to look for a new solution to replace its Oracle database. “We’ve been using MongoDB elsewhere in the business since 2014, and launched our first project on MongoDB Atlas in 2019,” revealed Valérie Pujol. “Adopting MongoDB Atlas for this project was a no brainer — it has the right document model and with our in-house expertise, we were confident we could migrate from Oracle to MongoDB Atlas with minimal disruption to customers.”
SNCF Connect & Tech stood up a multidisciplinary team and worked with MongoDB to design the solution. They defined the technical and security requirements around RTO, RPO, purging, and continuous backup, created the document model, and discussed the best way to transfer data into MongoDB Atlas.
The team developed an asynchronous process to transfer 130 million orders from the legacy database into MongoDB. They used an observability tool to monitor the migration in real-time and set up a recovery plan in the event of any disruption. Throttling mechanisms were put in place to guarantee optimal service quality by regulating the flow of data between the two databases.
The full data transfer took 18.5 hours, and a final transfer of order changes made 48 hours before the final switch took just 30 minutes.
The implementation was divided into four stages to gradually shift from Oracle to MongoDB Atlas. Performance, API reliability, batch processing, and scalability tests were carried out at every stage. “Our tests confirmed that MongoDB Atlas was the right choice — it couldn’t be faulted,” added Valérie Pujol. “For example, MongoDB write operations had no impact in terms of business API latency.”
Vincent Liboutet, Head of Product Managemen-IT, SNCF Connect & Tech
To optimize the performance of the MongoDB database, the team implemented a strict and systemic index management strategy. Indexes are split into two categories: technical and business, and were designed and tested to meet the needs of the application while minimizing impact on write operations.
“Technical indexes are mainly used to structure and organize collections according to the platform’s internal criteria. Business indexes have several use cases, such as enabling customers to find tickets by searching with reference number and customer name,” explained Valérie Pujol. “We also have several indexes for the extended search criteria used by customer support teams.”
A TTL index was placed on the ‘lastModifiedDate’ field for orders to automate purging. There’s also a trigger on the delete events of these collections to capture purged orders and launch an Atlas Function for the associated entries.
Planning for emergencies
To make sure the app could still access the right information if there was an issue during the migration to MongoDB Atlas, the team implemented a rollback. A collection mapped both Oracle and MongoDB identifiers down to sub-document level so the app could use the Oracle copy if the data wasn’t available from the primary source.
When the systems were running in parallel, they deployed a tool to classify any differences between the two databases generated by customer activity. This sped up impact analysis and corrective action, and the tool was used to identify the best time to switch to MongoDB as the primary database with no impact on users.
“Thanks to the commitment and expertise of our team and MongoDB, the migration was a resounding success,” said Valérie pujol. “The project was seamless and there was minimal disruption to SNCF Connect users.”
Vincent Liboutet, Head of Product Managemen-IT, SNCF Connect & Tech