Leveraging Cosmos DB for Publish/Subscribe in KnightBus: Analyzing Cosmos DB Performance Trade-offs and Guarantees
2025 (English)Independent thesis Advanced level (degree of Master (Two Years)), 20 credits / 30 HE credits
Student thesisAlternative title
Cosmos DB för Publish/Subscribe-kommunikation i KnightBus : Analys av prestandaavvägningar och garantier med Cosmos DB (Swedish)
Abstract [en]
Publish/Subscribe (Pub/Sub) is a design pattern widely used in modern communication, mainly for its ability to decouple producers and consumers. However, there is no one-size-fits-all design. Each implementation comes with a set of strengths and trade-offs, and selecting the most suitable implementation, therefore, depends entirely on the specific characteristics and requirements of the system. There is a lack of comparative performance studies between pub/sub implementations, a gap that is addressed by evaluating the performance of three Pub/Sub implementations within the open-source framework KnightBus. A novel transport based on Azure Cosmos DB was developed and benchmarked against existing implementations based on Azure Service Bus and PostgreSQL, with a focus on comparing throughput and publish latency across varied workloads, subscription patterns and operational conditions. Results demonstrate that Cosmos DB consistently achieves the highest cost-normalised throughput. Cosmos’ throughput also remains stable regardless of subscriber count. In contrast, the throughput degraded with the number of subscribers in the other transports. In latency benchmarks, PostgreSQL outperforms Cosmos and the Service Bus by a factor of two when publishing 1000 events to a node in Sweden. Conversely, Cosmos exhibits significantly faster publish times than the other two transports when publishing 1000 events to a node in New Zealand, explained by its multi-region write capabilities. For high-volume event publishing, PostgreSQL is consistently faster than the other implementations, regardless of node location. These results help guide developers choose a Pub/Sub transport tailored to their application’s specific needs. For applications with a high number of subscribers or requirements for event retention, Cosmos offers a scalable and cost-efficient solution. Conversely, PostgreSQL should be considered for applications prioritising low latency for bulk publishing.
Abstract [sv]
Publicera/prenumerera (Publish/Subscribe eller Pub/Sub) är ett designmönster som används flitigt I modern kommunikation, främst på grund av dess förmåga att separera producenter och prenumeranter. Det finns dock ingen universallösning utan varje implementation has sina styrkor och svagheter. Vilken implementation som är bäst lämpad beror därför helt på det specifika systemets egenskaper och krav. Det är väldigt begränsat med studier som jämför prestanda mellan olika implementationer, något denna studie behandlar genom att utvärdera tre implementationer i öppna ramverket KnightBus. En ny transport baserad på Azure Cosmos DB utvecklades och jämfördes med befintliga implementationer baserade på Azure Service Bus och PostgreSQL, med fokus på genomströmmning och publiceringslatens under varierade förhållanden. Resultaten visar att Cosmos konsekvent uppnår den högsta genomströmmingen samt att Cosmos genomströmming är stabil oberoende av antal prenumeranter på ämnet. Detta till skillnad från de andra transporterna där genomströmningen minskar i takt med att antalet prenumeranter ökar. I latenstester där databasen är i Sverige är PostgreSQL snabbare än både Cosmos och Service Bus oavsett antal publicerade händelser. När databasen är placerad i Nya Zeeland visar Cosmos betydligt mindre latens än dem andra transporterna vid publicering av 1000 händelser, vilket kan förklaras med dess möjlighet att skriva till flera regioner i kombination med den sekundära regionen i Sverige. Vid publicering av mer än 1000 händelser är PostgreSQL snabbast även med databasen i Nya Zeeland. Dessa resultat vägleder utvecklare i valet av pub/sub transport anpassad till applikationers specika behov. För applikationer med många prenumeranter eller krav på möjlighet till retroaktiva premenuationer erbjuder Cosmos en skalbar och kostnadseffektiv lösning. För applikationer där låg latens vid masspublicering är viktigast är PostgreSQL lämpligare.
Place, publisher, year, edition, pages
2025. , p. 41
Series
TRITA-EECS-EX ; 2025:483
Keywords [en]
Publish/Subscribe, KnightBus, Cosmos DB, Service Bus, PostgreSQL, Benchmark
Keywords [sv]
Publicera/prenumerera, KnightBus, Cosmos DB, Service Bus, PostgreSQL, systemtest
National Category
Computer and Information Sciences
Identifiers
URN: urn:nbn:se:kth:diva-368124OAI: oai:DiVA.org:kth-368124DiVA, id: diva2:1987380
External cooperation
BookBeat
Supervisors
Examiners
2025-08-112025-08-062025-08-11Bibliographically approved