Microservices Migration
HelloprintSep 2018 - Aug 2019
Drove Helloprint's move from a PrestaShop monolith to CQRS and event-sourced microservices on Kubernetes, including the payment integration.
Technologies Used
- Kubernetes
- Kafka
- PostgreSQL
- Contentful
- Prooph
- Docker
- PHP
- Event Sourcing
- CQRS
- Neo4j
Helloprint ran on a PrestaShop monolith that struggled during peak print traffic. I was on the team that built its new platform: CQRS and event-sourced microservices on Kubernetes (GKE). Using what I had learned at Namshi, I built the payment, logistics and login modules.
About Helloprint
Helloprint is an online marketplace for custom printed products: apparel, promotional items, gifts, packaging, photo products. Its customers range from freelancers and small businesses to non-profits and corporates.
It does not own the presses. Orders go to a network of more than 300 manufacturers in 31 countries, and software picks a producer and carrier close to the customer. Printing near the customer cuts cost, delivery time and shipping emissions.
Two sides, one platform
Helloprint has two sides. Business to business, with the printers and the rest of the supply chain. And business to customer, with the people ordering prints.
PrestaShop carried both, with a lot of customizations on top, and it was not the best fit for either. The next step was a resilient platform: Kafka with event sourcing and event streaming, and Neo4j for the supply chain on the business side. A lot of strong concepts, all built in PHP.
What I worked on
Splitting the monolith
- Helped draw service boundaries around business capabilities and who owns which data
- Gave each service its own database
- Built REST and GraphQL APIs between services
- Built the payment, logistics and login modules, so peak traffic no longer hit one shared monolith
CQRS and event sourcing
We used the Prooph framework in PHP. Writes went through command handlers and domain aggregates. Every change was stored as an event in a PostgreSQL event store. Reads came from projections built from those events.
That gave us a full history of every order and the option to replay events to rebuild state or chase a bug. It also gave us new problems: evolving event schemas without breaking old events, keeping projections in sync, and snapshots so replays stayed fast. Sagas coordinated workflows that crossed services.
Kafka and Kubernetes
Kafka carried events between services, with versioned event schemas and dead letter queues for failures. Services ran in Docker on Kubernetes, deployed with Helm charts through CI/CD pipelines, and monitored with Prometheus and Grafana.
Services talked to each other in two ways. Most sent messages: a service published to Kafka, Kafka handed the message to listeners in every system that cared, and the system as a whole was eventually consistent. Some calls could not wait for that. Login needs an answer right away, so those went as direct calls from one service to another.
Content
Contentful was the headless CMS. I worked on the integration with its APIs, caching, and keeping content in sync across environments.
Stack
Kubernetes, Docker, Helm, Kafka, PostgreSQL, PHP, Prooph, Contentful, Prometheus, Grafana.
What I took from it
Event sourcing is powerful and expensive. The audit trail and replay were worth it for orders. For simpler parts of the system, the extra moving pieces cost more than they gave back. I wrote about that later in When not to use event sourcing.
Microservices did the same. Teams could deploy on their own, but every boundary we added was one more thing to monitor and debug.