<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.9.2">Jekyll</generator><link href="http://marcospaulucci.dev/feed.xml" rel="self" type="application/atom+xml" /><link href="http://marcospaulucci.dev/" rel="alternate" type="text/html" /><updated>2022-08-01T22:56:21+00:00</updated><id>http://marcospaulucci.dev/feed.xml</id><title type="html">Marcos’s blog</title><subtitle>Marcos Paulucci's blog.</subtitle><author><name>Marcos Paulucci</name></author><entry><title type="html">Customer Segmentation at Glovo - Part 1</title><link href="http://marcospaulucci.dev/audience%20targeting,%20microservices,%20big%20data/segmentation-part-1/" rel="alternate" type="text/html" title="Customer Segmentation at Glovo - Part 1" /><published>2022-05-15T00:00:00+00:00</published><updated>2022-05-15T00:00:00+00:00</updated><id>http://marcospaulucci.dev/audience%20targeting,%20microservices,%20big%20data/segmentation-part-1</id><content type="html" xml:base="http://marcospaulucci.dev/audience%20targeting,%20microservices,%20big%20data/segmentation-part-1/">&lt;p style=&quot;text-align: center;&quot;&gt;&lt;img src=&quot;/assets/images/audience-targeting.jpeg&quot; alt=&quot;system design book&quot; height=&quot;200px&quot; width=&quot;200px&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Introduction to &lt;a href=&quot;https://about.glovoapp.com/&quot;&gt;Glovo&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;Glovo is a Spanish tech company that provides innovative solutions to connect customers, businesses and couriers to provide delivery services, and it is the fastest-growing multicategory player in Europe, Western Asia and Africa.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h1 id=&quot;part-1-what-is-segmentation-and-why-do-we-need-it&quot;&gt;Part 1: What is segmentation and why do we need it?&lt;/h1&gt;

&lt;p&gt;Segmentation was a challenging and interesting project that my colleague and friend &lt;a href=&quot;https://medium.com/@ahmad.ramadan-hamouda?source=post_page-----8d2ecef2549a--------------------------------&quot;&gt;Ahmad&lt;/a&gt; and I leaded, designed and implemented for our cluster and the whole company. Customer segmentation can be summarized by &lt;a href=&quot;https://en.wikipedia.org/wiki/Market_segmentation&quot;&gt;Wikipedia&lt;/a&gt; as:
“dividing a broad consumer or business market, normally consisting of existing and potential customers, into sub-groups of consumers (known as segments) based on some type of shared characteristics”.
The idea of segmenting the customer base had been around for more than an year at Glovo, with ongoing debates about how and who should take it. It seemed like a big challenge and pretty scary for some teams, but not for us! We had our own ideas about how to approach the different challenges of such a system, and finally after a long wait we got the opportunity to officially take on the project.&lt;/p&gt;

&lt;p&gt;This post is an adaptation of my original post in in Glovo’s Medium blog: &lt;a href=&quot;https://medium.com/glovo-engineering/customer-segmentation-at-glovo-8d2ecef2549a&quot;&gt;Customer Segmentation at Glovo
Part 1&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;business-context&quot;&gt;Business context&lt;/h2&gt;

&lt;p&gt;Glovo orchestrates a variety of discount campaigns. Before the Segmentation Service, these campaigns targeted our entire customer base, regardless of individual customer behavior or preference. For Glovo and its partners, this was highly inefficient in terms of budget and ROI, limiting customer acquisition, retention, and overall customer experience. We didn’t have a system capable of classifying the most appropriate discount campaign for each kind of customer. For example:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;users who never ordered from a specific store&lt;/li&gt;
  &lt;li&gt;users who haven’t ordered in the last month&lt;/li&gt;
  &lt;li&gt;users who order recurrently&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We began by providing a definition of this new concept called “Segmentation” and a new &lt;a href=&quot;https://martinfowler.com/bliki/BoundedContext.html&quot;&gt;bounded context&lt;/a&gt; called “Segments”; based on &lt;a href=&quot;https://martinfowler.com/tags/domain%20driven%20design.html&quot;&gt;DDD&lt;/a&gt; concepts. Its responsibility was to “categorize customers based on different traits such as their profile, their order history, analytic events, and machine learning models”.&lt;/p&gt;

&lt;h2 id=&quot;scope-for-an-mvp&quot;&gt;Scope for an MVP&lt;/h2&gt;

&lt;p&gt;We established the boundaries of our system and prioritized among the multiple stakeholders interested in different segment types. We needed a system capable of supporting most of their use cases. Therefore, we had to design the system properly with a focus on time to market, service response, scalability, and extensibility. Our first segment types were:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;New customers with 0 orders in certain stores&lt;/li&gt;
  &lt;li&gt;Customers ordering recurrently from some stores&lt;/li&gt;
  &lt;li&gt;Inactive customers who used to order in the past but they haven’t done so in a certain amount of time&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Time to market was a hard constraint, so we committed to delivering a solution in only 3 months. We aimed to cover the first segmentation cases but also build an extensible system, capable of supporting different types of segments for the remaining and future use cases.&lt;/p&gt;

&lt;h1 id=&quot;challenges&quot;&gt;Challenges&lt;/h1&gt;

&lt;h3 id=&quot;time-to-market&quot;&gt;Time-to-market&lt;/h3&gt;

&lt;p&gt;Our partners were in deep need and we didn’t want to lose their trust so we had to act fast and with vision.&lt;/p&gt;

&lt;h3 id=&quot;scaling-calculations&quot;&gt;Scaling calculations&lt;/h3&gt;

&lt;p&gt;We would start with only a few hundred segments but, shortly thereafter, would scale to hundreds of thousands of segments. A single segment calculation could involve millions of customers and hundreds of millions of order history items.&lt;/p&gt;

&lt;h3 id=&quot;fast-growing-data-volume&quot;&gt;Fast-growing data volume&lt;/h3&gt;

&lt;p&gt;Not only would the number of segments grow, but so would our customer base, order history, and other new data source involved. We had to prepare to process big data.&lt;/p&gt;

&lt;h3 id=&quot;serving-segments-with-high-availability-and-low-latency&quot;&gt;Serving segments with high availability and low latency&lt;/h3&gt;

&lt;p&gt;The segments would be used in most customer flows to customize the customer’s journey, so latency was a very crucial constraint and couldn’t be hurt. In other words, we committed to a tight &lt;a href=&quot;https://en.wikipedia.org/wiki/Service-level_agreement&quot;&gt;SLA&lt;/a&gt;, with an affordable latency of p99 &amp;lt;= 50 milliseconds and availability &amp;gt;= 99.99%&lt;/p&gt;

&lt;h3 id=&quot;offline-data-vs-real-time-data&quot;&gt;Offline data vs Real-time data&lt;/h3&gt;

&lt;p&gt;Processing and serving terabytes of data to millions of users was challenging, but having this system working with real-time data was even more difficult. Luckily, not all segments required live data, and they could work just fine with eventually consistent segments, with a few minutes delay for updates. We used this to our advantage and started by tackling the use cases that could be near real-time. This simplified our first version of the system, postponing the implementation of those other segments for later.&lt;/p&gt;

&lt;h3 id=&quot;integration&quot;&gt;Integration&lt;/h3&gt;

&lt;p&gt;How would these new customer segments be served to the whole Glovo ecosystem in a standardized way? We aimed for a solution that would be agnostic of the calling domain, but at the same time provide the required flexibility to serve each domain’s needs. Also, we wanted to integrate other components in the system that could possibly calculate other types of segments in their own way. For example, some Machine Learning models were already generating some kinds of customer segments, and we should be able to feed their results into our service just as a new type of segment.&lt;/p&gt;

&lt;h3 id=&quot;cost&quot;&gt;Cost&lt;/h3&gt;

&lt;p&gt;Cost doesn’t come only from marketing campaigns, but also from tech, ranging from infrastructure and maintenance costs to new feature development. The cost of the solution cannot be more expensive than the cost of losing partners or unhappy customers. For this project, we aimed for a solution that was cost-effective yet maintainable, reasonably extensible to cover our main use cases in the cluster, and easily evolvable to support new use cases. This allowed us to shorten the delivery of an MVP, meeting our strict time-to-market constraint.&lt;/p&gt;

&lt;h3 id=&quot;customer-ux-validation&quot;&gt;Customer UX validation&lt;/h3&gt;

&lt;p&gt;We used &lt;a href=&quot;https://martinfowler.com/articles/feature-toggles.html&quot;&gt;Feature toggles&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/A/B_testing&quot;&gt;AB testing&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;To customize each customer’s UX and applicable discounts&lt;/li&gt;
  &lt;li&gt;To compare the &lt;a href=&quot;https://en.wikipedia.org/wiki/Return_on_investment&quot;&gt;Return on Investment (ROI)&lt;/a&gt; against non-segmented discount campaigns&lt;/li&gt;
  &lt;li&gt;To assess the cost of customer acquisition, flexibility of defining new configurations, and scalability&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;high-level-architecture&quot;&gt;High-level architecture&lt;/h1&gt;

&lt;p&gt;Our segmentations component would serve data to the rest of the Glovo ecosystem like this:&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;&lt;img src=&quot;/assets/images/high-level.jpeg&quot; alt=&quot;system design book&quot; /&gt;&lt;/p&gt;

&lt;p&gt;We assessed the nonfunctional requirements and quickly realized that the segment’s calculation flows were quite different from the serving data; especially in terms of data volume and required latency. This led us to split calculations and reads into two different components on the architectural level. The &lt;strong&gt;Segments Core&lt;/strong&gt; would be responsible for calculating the segments by processing vast and diverse types of data. The &lt;strong&gt;Segment Store&lt;/strong&gt; would be responsible for serving the calculated segments to the rest of the system, with high availability and low latency. Having these two separate components would also allow us to choose the appropriate technologies for each task.&lt;/p&gt;

&lt;p&gt;If you are interested to know what the architecture looks like check &lt;a href=&quot;https://marcospaulucci.dev/audience%20targeting,%20microservices,%20big%20data/segmentation-part-2/&quot;&gt;part 2 “Segmentation service zoom in”!&lt;/a&gt;&lt;/p&gt;</content><author><name>Marcos Paulucci</name></author><category term="Audience targeting, microservices, big data" /><category term="Audience targeting, microservices, big data" /><summary type="html">Customer Segmentation at Glovo - Introduction</summary></entry><entry><title type="html">Customer Segmentation at Glovo - Part 2</title><link href="http://marcospaulucci.dev/audience%20targeting,%20microservices,%20big%20data/segmentation-part-2/" rel="alternate" type="text/html" title="Customer Segmentation at Glovo - Part 2" /><published>2022-05-15T00:00:00+00:00</published><updated>2022-05-15T00:00:00+00:00</updated><id>http://marcospaulucci.dev/audience%20targeting,%20microservices,%20big%20data/segmentation-part-2</id><content type="html" xml:base="http://marcospaulucci.dev/audience%20targeting,%20microservices,%20big%20data/segmentation-part-2/">&lt;p style=&quot;text-align: center;&quot;&gt;&lt;img src=&quot;/assets/images/segmentation_system_design.jpeg&quot; alt=&quot;system design book&quot; height=&quot;200px&quot; width=&quot;200px&quot; /&gt;&lt;/p&gt;

&lt;h1 id=&quot;part-2-segmentation-system-design&quot;&gt;Part 2: Segmentation system design&lt;/h1&gt;

&lt;p&gt;Note: This post is an adaptation of my original post in Glovo’s Medium blog &lt;a href=&quot;https://medium.com/glovo-engineering/customer-segmentation-at-glovo-8b46a787ac5e&quot;&gt;Customer Segmentation at Glovo
Part 2: Segmentation system design&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In &lt;a href=&quot;https://marcospaulucci.dev/audience%20targeting,%20microservices,%20big%20data/segmentation-part-1/&quot;&gt;part 1&lt;/a&gt;, we talked about the customer segmentation needs at Glovo and why we need to customize the customer’s UX. For example, we needed to target specific audiences for certain discounts. We also discussed the need to separate the segment’s calculations task from the segment’s restful API. In part 2, we will dive into the two components: explaining their respective responsibilities and the overall architecture.&lt;/p&gt;

&lt;p&gt;We named the two components “Core” and “Store”; the Core is responsible for performing Segment calculations in a scheduled fashion (every X minutes/hours), based on the segment definitions provided; the Store is in charge of segment configuration management and auditing, and also serving the calculated segments to the rest of the system. Also, between these components, we need integrations to exchange segment configurations and segment results, to finally expose those results to the external parties.&lt;/p&gt;

&lt;p&gt;See the full architecture below:&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;&lt;img src=&quot;/assets/images/segmentation-diagram.png&quot; alt=&quot;system design book&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Going into details for each component, integrations, and how the data flows:&lt;/p&gt;

&lt;h2 id=&quot;core&quot;&gt;Core&lt;/h2&gt;

&lt;p&gt;For data calculations, we decided to leverage Glovo’s existing Data Lake and Big Data tools. Here were our reasons:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;We knew we needed to query data from multiple domains, initially orders, users, and products but possibly many others in the future as we defined new segment types. The Data Lake, built on S3, solved this requirement out of the box. It is a centralized store already gathering data from most of the domains in the system. Although data in the Data Lake was not live data (it was refreshed every half an hour), we didn’t need live data for most of the segmentation cases.&lt;/li&gt;
  &lt;li&gt;Performing the segment calculations would involve hundreds of millions of rows, and terabytes of data. So it was clear to us that the best way to perform these calculations was using Big Data processing tools. At Glovo we use &lt;a href=&quot;https://aws.amazon.com/emr/&quot;&gt;AWS EMR&lt;/a&gt; and &lt;a href=&quot;https://spark.apache.org/docs/latest/api/python/&quot;&gt;PySpark&lt;/a&gt; to run calculations on the Data Lake.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The full stack for the core included also &lt;a href=&quot;https://www.jenkins.io/&quot;&gt;Jenkins&lt;/a&gt; and &lt;a href=&quot;https://luigi.readthedocs.io/en/stable/&quot;&gt;Luigi&lt;/a&gt;. New segment calculations would be put in an &lt;a href=&quot;https://aws.amazon.com/s3/&quot;&gt;S3&lt;/a&gt; prefix for the given DateTime, and historical data could be eventually deleted by using &lt;a href=&quot;https://docs.aws.amazon.com/AmazonS3/latest/userguide/lifecycle-expire-general-considerations.html&quot;&gt;object expiration policies&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;store&quot;&gt;Store&lt;/h2&gt;

&lt;p&gt;As this component is responsible for segment configurations management and also serving segment calculations, it includes several parts: the backend exposing a restful API, an RDBMS holding the segment configurations, an Elastic search cluster to store and serve the segments calculations to the backend, and Redis for caching customer-segments queries to achieve the low latency needed.&lt;/p&gt;

&lt;p&gt;As explained earlier, in order to move the calculated segments from the Store to the Core, we designed an ingestion process.&lt;/p&gt;

&lt;h2 id=&quot;elasticsearch&quot;&gt;Elasticsearch&lt;/h2&gt;

&lt;p&gt;We took multiple factors into consideration to select the proper data store for segment calculations search. First and foremost, was the volume of data initial estimations. We expected 1K segments to be created by the business and partners for the initial phase. Beyond that, we anticipated over 100K segments once more segment types were added. Each one of these segments could have millions of customers and on average be around 50 MB. The second critical factor was that a given customer could belong to a multitiude of segments but different stakeholders would only be interested in a subset of segments for a given customer. For example, one might only care about segments for a particular store, or specific categories (pharmacies, not restaurants), and so forth. This meant we needed a search engine that could scale horizontally and was capable of querying by multiple, unbounded fields. And potentially, in the future, use-cases using text search. We agreed the best choice was &lt;a href=&quot;https://www.elastic.co/?ultron=B-Stack-Trials-EMEA-S-Exact&amp;amp;gambit=Stack-Core&amp;amp;blade=adwords-s&amp;amp;hulk=paid&amp;amp;Device=c&amp;amp;thor=elasticsearch&amp;amp;gclid=Cj0KCQjwm6KUBhC3ARIsACIwxBioYniNLnDpcTPIcOzFfCmwoZ2FVsBmK8als7BUqBmvVXQM8G7BOK0aAv0oEALw_wcB&quot;&gt;ElasticSearch&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;We faced several interesting and challenging points during the ElasticSearch setup. We discovered performance improvements by using &lt;a href=&quot;https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-term-query.html&quot;&gt;term queries&lt;/a&gt; from our Spring elastic client. We learned to select the proper data types for each indexed field (such as using &lt;a href=&quot;https://www.elastic.co/guide/en/elasticsearch/reference/current/keyword.html#keyword-field-type&quot;&gt;keyword&lt;/a&gt; type for id fields). We also tweaked the elastic &lt;a href=&quot;https://www.elastic.co/guide/en/elasticsearch/reference/current/tune-for-indexing-speed.html#:~:text=By%20default%2C%20Elasticsearch%20periodically%20refreshes,in%20the%20last%2030%20seconds.&quot;&gt;index refresh rate&lt;/a&gt; to reduce the latencies of the queries and partitioned large docs to remain below the &lt;a href=&quot;https://www.elastic.co/guide/en/app-search/current/limits.html&quot;&gt;maximum document size&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;store-clusters-api-and-ingestion&quot;&gt;Store clusters: Api and Ingestion&lt;/h2&gt;

&lt;p&gt;Given the very different workloads of ingesting data from the Core and serving that data to outside domains, we opted for separate clusters for each task; splitting reads and writes. This would allow us to ingest in a decoupled and efficient way, scaling each cluster independently.&lt;/p&gt;

&lt;p&gt;The ingestion flow would work as follows: When the task to process a new calculation is triggered, the &lt;a href=&quot;https://spark.apache.org/docs/latest/api/python/&quot;&gt;PySpark&lt;/a&gt; cluster starts generating segments that are later ingested by the Store Ingestion cluster and stored in a new Elastic Search index. To achieve efficient ingestion we leveraged several techniques:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;We used &lt;a href=&quot;https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html&quot;&gt;“Elastic Search alias switch”&lt;/a&gt; to quickly swap between the old and the new index.&lt;/li&gt;
  &lt;li&gt;We used Elastic’s &lt;a href=&quot;https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html&quot;&gt;bulk API&lt;/a&gt;, parallelization, and retries in case of errors to efficiently insert into Elastic Search.&lt;/li&gt;
  &lt;li&gt;We used a Redis lock and tweaked the message visibility timeout to expire old messages so as to have an at-most-once semantic; distinct from the at-least-once of &lt;a href=&quot;https://aws.amazon.com/sqs/&quot;&gt;SQS&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;redis-cache-in-the-api-cluster&quot;&gt;Redis Cache in the API Cluster&lt;/h2&gt;

&lt;p&gt;We had committed to an SLO of p99 &amp;lt; 50ms and to achieve it we leveraged the eventually-consistent nature of the segment calculations we were serving. We could cache heavily without worrying so much about the &lt;a href=&quot;https://redis.io/commands/expire/#:~:text=Normally%20Redis%20keys%20are%20created,instance%20using%20the%20DEL%20command.&quot;&gt;time to live (TTL)&lt;/a&gt; of the entries or the cache invalidation. With Redis as a simple &lt;a href=&quot;https://docs.aws.amazon.com/whitepapers/latest/database-caching-strategies-using-redis/caching-patterns.html&quot;&gt;cache-aside&lt;/a&gt; strategy, we cached the most frequently accessed customer segments. Not only did we drop the latency to less than 10ms but we also reduced the load on the Elastic cluster. Before adding Redis due to a load of requests [10K / sec at the peak] elastic was going up to the 250ms, at least for some of the requests.&lt;/p&gt;
&lt;p style=&quot;text-align: center;&quot;&gt;&lt;img src=&quot;/assets/images/cache-aside.jpg&quot; alt=&quot;system design book&quot; /&gt;&lt;/p&gt;

&lt;h1 id=&quot;rollout-checklist&quot;&gt;Rollout Checklist&lt;/h1&gt;

&lt;p&gt;Before we rolled out the project, we had a large checklist to validate the readiness of the multiple components and clients. We prepared an exhaustive rollout plan to minimize the chances of failure and to be ready for possible rollbacks. We also ensured documentation is in a centralized place, including the design, observability links, and &lt;a href=&quot;https://swagger.io/specification/&quot;&gt;OpenAPI Specification&lt;/a&gt; of our Restful endpoints. The rollout would start in a single city, then expand to the whole country, and finally to other countries. The gradual increase in the traffic could unveil any errors or performance issues early. AB tests were used to validate the results.&lt;/p&gt;

&lt;h3 id=&quot;performance-testing&quot;&gt;Performance testing&lt;/h3&gt;

&lt;p&gt;To accommodate the load from the client domains, we had to define initial sizes for our API, Ingestion, ElasticSearch, and ElastiCache clusters. Since we didn’t have a proper load testing tool by that time, we used JMeter to perform a first load test on the service. Later we enabled &lt;a href=&quot;https://microsoft.github.io/code-with-engineering-playbook/automated-testing/shadow-testing/&quot;&gt;shadow traffic&lt;/a&gt; from the real clients with all the proper observability around the key metrics. We adjusted the clusters node minimum and maximum node count, the node instance sizes, storage types, etc. until we reached the performance we required. Beyond that, autoscaling would adapt according to the load.&lt;/p&gt;

&lt;h3 id=&quot;resiliency&quot;&gt;Resiliency&lt;/h3&gt;

&lt;p&gt;We couldn’t risk harming our existing clients’ SLOs and we had to define our Segmentation SLO respecting the &lt;a href=&quot;https://www.ibm.com/docs/ru/imdm/11.6?topic=solution-integrating-upstream-downstream-systems&quot;&gt;upstream&lt;/a&gt; services. On the ingestion process side, resilience was needed when reading segment parts from S3 and persisting to ElasticSearch. Moreover, we didn’t want to halt the entire ingestion of terabytes of data when a single part, out of thousands, would fail so we set up error tolerance rates. On the Elastic side, we wanted to keep the previously ingested data from old indexes for a while. In this case, the new index wouldn’t be created for failures during segments calculations or ingestion. Therefore, we used indexes &lt;a href=&quot;https://www.elastic.co/guide/en/elasticsearch/reference/current/getting-started-index-lifecycle-management.html#ilm-gs-create-policy&quot;&gt;lifecycle policies&lt;/a&gt;. Finally, the client’s synchronous calls to our API cluster were protected with &lt;a href=&quot;https://martinfowler.com/bliki/CircuitBreaker.html&quot;&gt;circuit breakers&lt;/a&gt;, timeouts, and retries.&lt;/p&gt;

&lt;h3 id=&quot;observability&quot;&gt;Observability&lt;/h3&gt;

&lt;p&gt;To deliver the project proper observability was critical. This included logs, metrics, dashboards, monitors, and alerts. Initially, the alerts would point to a dedicated &lt;a href=&quot;https://slack.com/&quot;&gt;Slack&lt;/a&gt; channel and later promoted to &lt;a href=&quot;https://www.pagerduty.com/&quot;&gt;Pagerduty&lt;/a&gt; to reach the on-call engineer. On-call &lt;a href=&quot;https://www.pagerduty.com/resources/learn/what-is-a-runbook/&quot;&gt;run-books&lt;/a&gt; were updated as well.&lt;/p&gt;

&lt;p&gt;Main observability resources:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Datadog’s &lt;a href=&quot;https://www.datadoghq.com/dg/apm/ts-benefits-os/?utm_source=advertisement&amp;amp;utm_medium=search&amp;amp;utm_campaign=dg-google-apm-emea-general&amp;amp;utm_keyword=application%20performance%20monitoring&amp;amp;utm_matchtype=p&amp;amp;utm_campaignid=15419168583&amp;amp;utm_adgroupid=131788862153&amp;amp;gclid=CjwKCAjw4ayUBhA4EiwATWyBrj374lFcZmYeTkTWO_ptkxUE3Xat4CXbiSWcNPFcBpQBTdiv-6fDfRoCOEgQAvD_BwE&quot;&gt;Application Performance Monitoring (APM)&lt;/a&gt; for our different clusters, including API, Ingestion, and ElasticSearch.&lt;/li&gt;
  &lt;li&gt;General segmentation metrics dashboard, including endpoints, ingestions, segments calculations, SQS queues, and HTTP Client’s health&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.elastic.co/kibana?ultron=B-Stack-Trials-EMEA-S-Exact&amp;amp;gambit=Stack-Kibana&amp;amp;blade=adwords-s&amp;amp;hulk=paid&amp;amp;Device=c&amp;amp;thor=kibana&amp;amp;gclid=CjwKCAjw4ayUBhA4EiwATWyBrj5MadTXgXR4k8pHPMhsQqNn3q24SngGmtw2Ur0VA91FNZ2phlj0bBoCUx4QAvD_BwE&quot;&gt;Kibana&lt;/a&gt; to keep track of the index’s status, including their size, document count, and policies, and to have a handy way to execute queries against Elastic.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;rollout-results-and-next-steps&quot;&gt;Rollout results and next steps&lt;/h2&gt;

&lt;p&gt;The production rollout was a success, no downtime nor rollbacks were needed. The application was already serving up to 10K requests per second, with a p99 of 12.05ms on average, and p75 avg 1.23ms.&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;&lt;img src=&quot;/assets/images/datadog-dashboard.jpeg&quot; alt=&quot;system design book&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Segmentation has been a success for the business, increasing the conversion rate for discounts for new customers. Analysts using our AB-testing tools and Data warehouse are still gathering insights about the impact, as they also explore how we can further leverage the segmentation capabilities to increase our customer base and personalize each customer’s experience across Glovo’s platform. As Segmentation starts gaining traction in the company and new interests arise, other teams are starting to explore how they can benefit from it, and we anticipate various improvements to how segmentation works in the future.&lt;/p&gt;</content><author><name>Marcos Paulucci</name></author><category term="Audience targeting, microservices, big data" /><category term="Audience targeting, microservices, big data" /><summary type="html">Customer Segmentation at Glovo - System design</summary></entry><entry><title type="html">Learnings from team rotations</title><link href="http://marcospaulucci.dev/modularization/team-rotation-learnings/" rel="alternate" type="text/html" title="Learnings from team rotations" /><published>2021-10-12T00:00:00+00:00</published><updated>2021-10-12T00:00:00+00:00</updated><id>http://marcospaulucci.dev/modularization/team-rotation-learnings</id><content type="html" xml:base="http://marcospaulucci.dev/modularization/team-rotation-learnings/">&lt;p&gt;Introduction to &lt;a href=&quot;https://about.glovoapp.com/&quot;&gt;Glovo&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;Glovo is a Spanish tech company that provides innovative solutions to connect customers, businesses and couriers to provide delivery services, and it is the fastest-growing multicategory player in Europe, Western Asia and Africa.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h1 id=&quot;team-rotations-at-glovo&quot;&gt;Team rotations at Glovo&lt;/h1&gt;

&lt;p&gt;This post is a replica of my &lt;a href=&quot;https://medium.com/glovo-engineering/erasmus-like-engineering-rotations-a-tool-for-knowledge-sharing-78ee01893ccf&quot;&gt;original post&lt;/a&gt; in Glovo’s Medium blog.&lt;/p&gt;

&lt;p&gt;In this post we describe the experience of a team rotation, how it went and the lessons we learned.&lt;/p&gt;

&lt;h1 id=&quot;introduction&quot;&gt;Introduction&lt;/h1&gt;

&lt;p&gt;I rotated to the Organic Growth team for three sprints to help cover an engineer that was about to go on paternity leave. Coming from a year of working in Promotions and Discounts domains it was an opportunity to try out something different. The Organic team owns the “domain responsible to acquire new customers organically”, things like Search Engine Optimisation (SEO).&lt;/p&gt;

&lt;h1 id=&quot;the-tech-stack&quot;&gt;The tech stack&lt;/h1&gt;

&lt;p&gt;Before jumping to the rotation itself, the tech stack and way of working at Glovo: we use a large set of technologies, yet the most widely used stack in the Backend is Java 8, Spring framework, Gradle, and AWS Aurora — MySQL and several others. Our teams are agile and multidisciplinary, consisting mostly of backenders, frontenders, mobile engineers, data analysts, BI engineers, an Engineering Manager and a Product Manager.&lt;/p&gt;

&lt;p&gt;Although Organic was a rather new team — just 6 months old, I found well-grounded engineers and managers with a solid understanding of Glovo’s ecosystem (being at Glovo for a while already, I didn’t expect any less). I was onboarded very nicely to the team, so I could hit the ground running. Jumping to their Scrum ceremonies, I was surprised to find how closely the team worked, how fluent the communication was, and how efficient the participation/collaboration across projects and stacks was (Frontenders contributing in Backend tasks analysis and estimations and vice versa). Plus the way of calculating story points and estimating the capacity of the team for the Scrum Sprint per stack was very precise. I found these exchanges to be very helpful to understand what the rest of the engineers were working on.&lt;/p&gt;

&lt;h1 id=&quot;the-project&quot;&gt;The project&lt;/h1&gt;

&lt;p&gt;The project I joined was about publishing our partner’s information to Google Maps via SFTP, in order to enable placing orders from our Glovo app. First I reviewed the requirements, the proposed solution and architecture. It seemed a rather simple task: gather data from the DB, transform it and push it to the external system. Yet at Glovo few things are that easy. We had to process over 100K entries in one go (otherwise if disconnected google would discard the partially uploaded file), minimising the risks of impacting our huge and sensitive monolithic DB with long-running transactions, and watching out for the JVM memory footprint during the process. Also, we had to consider the monolith CI/CD times of up to 3 hs from merge to production (partly caused by the growth rate of the data, new logic added every hour and an ongoing microservices migration). And as if these were not enough, we had a file size restriction of 200MB max on Google’s api as well.&lt;/p&gt;

&lt;h1 id=&quot;challenges-and-solutions&quot;&gt;Challenges and solutions&lt;/h1&gt;

&lt;p&gt;Most of these challenges were easily overcome by decoupling the producer and consumer, using batching and &lt;a href=&quot;https://www.baeldung.com/spring-data-jpa-projections&quot;&gt;DTO projections&lt;/a&gt; when reading from the DB, pushing the data in chunks, covering new flows behind &lt;a href=&quot;https://martinfowler.com/articles/feature-toggles.html&quot;&gt;feature toggles&lt;/a&gt;, and making sure we had proper metrics and monitoring (for which we use &lt;a href=&quot;https://www.datadoghq.com/blog/monitoring-101-collecting-data/&quot;&gt;Datadog&lt;/a&gt; with Infra as code by &lt;a href=&quot;https://www.terraform.io/&quot;&gt;Terraform&lt;/a&gt;). About the large file size and execution times, gzipping the stream brought a big improvement: the time of the task went from 54 min to 16 min, and the size of the file from 60MB to just 7MB.&lt;/p&gt;

&lt;h2 id=&quot;the-modular-monolith&quot;&gt;The modular monolith&lt;/h2&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;&lt;img src=&quot;/assets/images/modular-monolith.jpeg&quot; alt=&quot;system design book&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The long execution times of the test suites in the monolith (with its heavy Spring context loading times, constantly growing) were not exciting at all, especially after coming from months of working on the Discounts microservice. Although this new project was initially proposed as a microservice, it wasn’t big enough to justify a whole new infra setup. So what then? The Organic backenders proposed to use an approach based on &lt;a href=&quot;https://martinfowler.com/tags/domain%20driven%20design.html#:~:text=Domain%2DDriven%20Design%20is%20an,through%20a%20catalog%20of%20patterns.&quot;&gt;domain-driven design&lt;/a&gt; and &lt;a href=&quot;https://netflixtechblog.com/ready-for-changes-with-hexagonal-architecture-b315ec967749&quot;&gt;ports and adapters&lt;/a&gt; that had worked pretty well in another project: create the code for the new bounded context in a fully decoupled gradle module, with no dependencies to the core monolith domain. Only a few adapters would live in the monolith module, implementing the corresponding ports from our core module. This way the core domain was simple and with a fast suite of Unit and Integration tests. I found that working in this way was a breath of fresh air when working in the monolith.&lt;/p&gt;

&lt;h1 id=&quot;results&quot;&gt;Results&lt;/h1&gt;

&lt;p&gt;On my last day, we already had our production data being pushed to Google and validated, and we were wrapping up some additional monitoring and a final refactor. Now I’m going back to my original team, glad to have met Organic people and exchanged ideas, and eager to put my learnings into practice in a big new project that’s just starting.&lt;/p&gt;</content><author><name>Marcos Paulucci</name></author><category term="Modularization" /><category term="Modularization" /><summary type="html">My learnings from my recent team rotation</summary></entry><entry><title type="html">The Discounts microservice</title><link href="http://marcospaulucci.dev/distributed%20systems/the-discounts-microservice/" rel="alternate" type="text/html" title="The Discounts microservice" /><published>2021-07-01T00:00:00+00:00</published><updated>2021-07-01T00:00:00+00:00</updated><id>http://marcospaulucci.dev/distributed%20systems/the-discounts-microservice</id><content type="html" xml:base="http://marcospaulucci.dev/distributed%20systems/the-discounts-microservice/">&lt;p&gt;Introduction to &lt;a href=&quot;https://about.glovoapp.com/&quot;&gt;Glovo&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;Glovo is a Spanish tech company that provides innovative solutions to connect customers, businesses and couriers to provide delivery services, and it is the fastest-growing multicategory player in Europe, Western Asia and Africa.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h1 id=&quot;discounts-inception&quot;&gt;Discounts inception&lt;/h1&gt;

&lt;p&gt;This post is a copy of my &lt;a href=&quot;https://medium.com/glovo-engineering/the-discounts-microservice-14f4d4e4d6c9&quot;&gt;original post&lt;/a&gt; in Glovo’s Medium blog.&lt;/p&gt;

&lt;p&gt;The Discount microservice was an interesting and challenging project. I was appointed to work on the architecture design and the analysis of the extraction process from the monolith. Later after the analysis, we would work on the implementation of an MVP.&lt;/p&gt;

&lt;p&gt;Glovo had started the monolith to microservices path some months ago, and there was no standardised path nor much internal experience on the topic; Discounts would be the first microservice in our cluster. On the other hand, business stakeholders were not ready to halt feature development for a microservice extraction.&lt;/p&gt;

&lt;h1 id=&quot;discounts-at-glovo&quot;&gt;Discounts at Glovo&lt;/h1&gt;

&lt;p&gt;Our team had analysed and defined the discounts domain boundaries and responsibilities, and now the goal was to create this domain. At Glovo, discounts come from diverse origins, and we needed a centralised place to govern them all, supporting the same rulesets to enable existing and future discount types efficiently. An example would be enabling discounts for a given set of stores, discounts for only a subset of store types (like pharmacies but not supermarkets), or discounts for prime users only. So, for the Discounts inception, it was paramount to provide an MVP with an extensible architecture capable of covering upcoming features in our roadmap.&lt;/p&gt;

&lt;h2 id=&quot;why-do-we-need-microservices&quot;&gt;Why do we need Microservices?&lt;/h2&gt;

&lt;p&gt;The long-term goal of the whole tech team was to split the monolith into smaller cohesive units, around well-defined &lt;a href=&quot;https://martinfowler.com/bliki/BoundedContext.html&quot;&gt;bounded contexts&lt;/a&gt;, because the big ball of mud had become an increasing burden, impacting development experience as well as business, causing downtime as it kept on growing in complexity and data.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Single_point_of_failure&quot;&gt;SPoF&lt;/a&gt;: a monolithic architecture where multiple domains coexist in the same deployment unit and also share the same underlying infrastructure tends to be more fragile than a distributed architecture using resiliency patterns&lt;/li&gt;
  &lt;li&gt;Flaky tests halt the CI pipeline every day.&lt;/li&gt;
  &lt;li&gt;Heavy local development environment.&lt;/li&gt;
  &lt;li&gt;The monolithic relational database (Aurora MySQL) with ever-worsening issues (long-running transactions, deadlocks, high commit latency, among others) and reaching the maximum vertical scaling limit.&lt;/li&gt;
  &lt;li&gt;Overall, slow &lt;a href=&quot;https://cio-wiki.org/wiki/Software_Development_Life_Cycle_(SDLC)&quot;&gt;Software Development Life Cycle&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Also moving away from the monolith would allow our team to be faster, more flexible, resilient, and scale independently.&lt;/p&gt;

&lt;p&gt;Where we were:&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;&lt;img src=&quot;/assets/images/where-we-were.jpeg&quot; alt=&quot;system design book&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Long term goal (simplified):&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;&lt;img src=&quot;/assets/images/where-we-wanted-to-be.jpeg&quot; alt=&quot;system design book&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;what-about-a-modular-monolith&quot;&gt;What about a modular monolith?&lt;/h2&gt;

&lt;p&gt;At Glovo we have a &lt;a href=&quot;https://modularmonolith.net/&quot;&gt;modular monolith&lt;/a&gt;, and for this project, we had considered the alternative of modularising our domain as a first step before moving on with the extraction to a microservice. The main advantage of starting with a module was the lower engineering effort, and shorter time for a milestone; yet the disadvantages of remaining in the monolith outweighed the advantages:&lt;/p&gt;

&lt;p&gt;Our new discounts DB model and data would put a strain on the Monolithic DB, and any discounts incident arising inside the monolith could bring the whole system down. That’s why we decided to go straight for a microservice.&lt;/p&gt;

&lt;h2 id=&quot;code-reuse-in-a-distributed-architecture&quot;&gt;Code reuse in a distributed architecture&lt;/h2&gt;

&lt;p&gt;Most of the code in our new domain was brand new, but not all of it: we had specific logic we needed to migrate. This brought the next question: how should we manage code reuse within our distributed architecture? We knew several strategies, like shared libraries, shared services, service mesh sidecars, and code replication. To choose one, we had to contrast them against our case: we had a discount logic inside a few classes, and we knew that this code wouldn’t be changed during our extraction phase. It looked like a very good match for the code replication strategy!&lt;/p&gt;

&lt;p&gt;In the code replication strategy, shared code is copied into each service source code (in our case the discounts service and the monolith). This strategy was certainly going against the &lt;a href=&quot;https://en.wikipedia.org/wiki/Don%27t_repeat_yourself&quot;&gt;DRY principle&lt;/a&gt;. We had to be cautious and confident that changes or bug fixes wouldn’t come, as it would have been very risky to update the replicated code in different places. But for our case, we were confident there was not much risk; plus any other alternative, such as creating a shared library would have been overkill. And so we decided to copy these classes from the monolithic codebase to the microservice. After the MVP was delivered successfully, we were safe to remove the duplicated code from the monolith.&lt;/p&gt;

&lt;h2 id=&quot;key-analysis-and-design-decisions&quot;&gt;Key analysis and design decisions&lt;/h2&gt;

&lt;h3 id=&quot;database-analysis-and-choice&quot;&gt;Database Analysis and Choice&lt;/h3&gt;

&lt;p&gt;Much of the traffic coming from customers would go through our new service, most of it for store navigation and checkout. The service would be read-heavy.&lt;/p&gt;

&lt;p&gt;We estimated approximately 1.63M rows for the initial phase of the roadmap, and with the expected growth in the next 3 years would grow to 25.3M. Since we would extract each discount type from the monolith one by one, our DB model wasn’t defined and would evolve. These factors made us go for a relational Aurora MySQL DB. The use of Indexes would be crucial, and denormalization was among our options as well. To help with the load and latency we proposed to use &lt;a href=&quot;https://aws.amazon.com/es/elasticache/redis/&quot;&gt;ElastiCache-Redis&lt;/a&gt;. We had a strategy for table partitioning by region as well.&lt;/p&gt;

&lt;h3 id=&quot;event-driven-design&quot;&gt;Event-driven design&lt;/h3&gt;

&lt;p&gt;The Discounts service would consume &lt;a href=&quot;https://aws.amazon.com/kinesis/?nc1=h_ls&quot;&gt;Kinesis events&lt;/a&gt; from each different discount provider to transform this information into its own model and persist it in the Datastore. By using remote events, new discounts would become available soon after being created in the provider’s domains, but not instantly. With this event-driven architecture, we had to embrace eventual consistency, a necessary sacrifice to allow decoupling and scaling.&lt;/p&gt;

&lt;h3 id=&quot;eventual-consistency-challenges&quot;&gt;Eventual consistency challenges&lt;/h3&gt;

&lt;p&gt;As the service would consume events to stay up to date, the eventual consistency brought the challenge of inconsistent states. To handle these cases we came up with a strategy to temporarily disable discounts in use, by using &lt;a href=&quot;https://redis.io/docs/reference/patterns/distributed-locks/&quot;&gt;distributed locking&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;A simplified diagram of the happy path:&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;&lt;img src=&quot;/assets/images/happy-path.jpeg&quot; alt=&quot;system design book&quot; /&gt;&lt;/p&gt;

&lt;p&gt;In the unhappy path, things go wrong (as they normally do) and Customer 1 doesn’t release the lock, the lock expires.&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;&lt;img src=&quot;/assets/images/unhappy-path.jpeg&quot; alt=&quot;system design book&quot; /&gt;&lt;/p&gt;

&lt;p&gt;For these cases, we need &lt;a href=&quot;https://en.wikipedia.org/wiki/Compensating_transaction&quot;&gt;compensating transactions&lt;/a&gt; that can trigger flows to correct the situation.&lt;/p&gt;

&lt;h3 id=&quot;more-distributed-systems-challenges&quot;&gt;More distributed systems challenges&lt;/h3&gt;

&lt;p&gt;Moving to a distributed architecture meant leaving ACID transactions behind and embracing eventual consistency. But also we had to account for the new network hops and the issues they bring. Discounts write flows would consume remote events to transform and persist them locally as discounts, but our read flows (i.e serving data) would be synchronous: Discount clients had to retrieve discounts from our Restful API, and we had to comply with an SLA of 99.99%, as the discounts were being served to most of the flows within the Glovo app.&lt;/p&gt;

&lt;p&gt;Another mandatory requisite was to perform a smooth transition to our service, with no downtime: to achieve that we had to make sure none of the components were misconfigured or failing, plus we needed to test the actual latency between the monolith and our service. By then we didn’t have proper performance or load testing tools at Glovo, so we decided to use a traffic mirroring technique.&lt;/p&gt;

&lt;h3 id=&quot;introducing-the-discounts-sdk-and-stability-patterns&quot;&gt;Introducing the Discounts SDK and Stability patterns&lt;/h3&gt;

&lt;p&gt;To deal with synchronous communication issues and also have a traffic mirroring tool, we created our Discounts SDK, which included an HTTP Client wrapped with &lt;a href=&quot;https://resilience4j.readme.io/docs&quot;&gt;resilience4j&lt;/a&gt; to use some of the &lt;a href=&quot;https://github.com/csabapalfi/release-it/blob/master/3-stability_patterns.md&quot;&gt;stability patterns&lt;/a&gt; it provides, in particular circuit breakers, timeouts, and fallback responses to the local discounts search. We leveraged these patterns from the moment we started sending the shadow traffic.&lt;/p&gt;

&lt;p&gt;With the shadow traffic, we gathered business and performance metrics, validating the correctness of the discount responses by comparing against local discounts search, and checking the latency was acceptable and no unexpected errors or misconfigurations were introduced. Finally, with our SDK we could control the gradual shift between the deprecated local monolithic discounts search and the new remote discounts in a &lt;a href=&quot;https://martinfowler.com/bliki/BranchByAbstraction.html&quot;&gt;branch by abstraction&lt;/a&gt; fashion. To achieve this and also to have a kill switch we used &lt;a href=&quot;https://martinfowler.com/articles/feature-toggles.html&quot;&gt;feature toggles&lt;/a&gt;. That’s how we performed production load and correctness tests, apart from the Unit and Integration tests we had in our CI pipeline.&lt;/p&gt;

&lt;h1 id=&quot;other-interesting-tasks&quot;&gt;Other interesting tasks&lt;/h1&gt;

&lt;p&gt;Some relevant tasks that we delivered:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Setup of the Continuous blue/green deployments using &lt;a href=&quot;https://spinnaker.io/&quot;&gt;Spinnaker&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Adding &lt;a href=&quot;https://www.datadoghq.com/lpg/?utm_source=advertisement&amp;amp;utm_medium=search&amp;amp;utm_campaign=dg-google-brand-ww&amp;amp;utm_keyword=%2Bdatadog&amp;amp;utm_matchtype=b&amp;amp;utm_campaignid=9551169254&amp;amp;utm_adgroupid=95325237782&amp;amp;gclid=Cj0KCQjwyMiTBhDKARIsAAJ-9VszShDTIVbj0WhGZUScKt6W0IPzhu8Dn8TElbB83o7anqfqDqWgQiIaAi6rEALw_wcB&quot;&gt;Datadog&lt;/a&gt; observability and monitoring for client and server errors, remote event consumers, centralised metrics dashboard, remote traffic results, and Circuit breaker errors. This all using &lt;a href=&quot;https://en.wikipedia.org/wiki/Infrastructure_as_code&quot;&gt;infrastructure as code&lt;/a&gt; with Terraform&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://flywaydb.org/&quot;&gt;Flyway&lt;/a&gt; migrations setup&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;outcome&quot;&gt;Outcome&lt;/h1&gt;

&lt;p&gt;After the MVP was successfully delivered and fully enabled in production, we measured additional technical and business improvements:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Removed almost 170 &lt;a href=&quot;https://en.wikipedia.org/wiki/Queries_per_second&quot;&gt;Queries Per Second(QPS)&lt;/a&gt; from the writer instance of the monolithic DB, and 440 QPS from the readers&lt;/li&gt;
  &lt;li&gt;Test Suite execution time went from more than 30min ( the usual monolith test times) to less than three minutes in our new CI pipeline&lt;/li&gt;
  &lt;li&gt;Mean-time to production went from 2.5hrs (monolith spinnaker pipeline, when the pipeline is not blocked!) to just around 1 hour in our own CI/CD pipeline.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All these improved KPIs translated into much faster and safer project deliveries and engineering time savings.&lt;/p&gt;

&lt;h1 id=&quot;present&quot;&gt;Present&lt;/h1&gt;

&lt;p&gt;After the MVP fellow engineers continued to work and expanded the Discounts service capabilities. At the moment of posting, the discounts service has evolved to support several types of discounts, and new ones are still being migrated and created.&lt;/p&gt;

&lt;h2 id=&quot;references&quot;&gt;References&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://microservices.io/book&quot;&gt;Microservices patterns — Chris Richardson&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://samnewman.io/books/monolith-to-microservices/&quot;&gt;Monolith to microservices — Sam Newman&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://pragprog.com/titles/mnee2/release-it-second-edition/&quot;&gt;Release It — Michael Nygard&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraMySQL.Replication.html&quot;&gt;AWS Aurora Master-Slave architecture&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://martin.kleppmann.com/2016/02/08/how-to-do-distributed-locking.html&quot;&gt;Distributed locks — Martin Kleppmann&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://microservices.io/patterns/data/saga.html&quot;&gt;Saga pattern&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://learning.oreilly.com/library/view/software-architecture-the/9781492086888/&quot;&gt;Software Architecture The Hard Parts — Neal Ford, Mark Richards&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content><author><name>Marcos Paulucci</name></author><category term="Distributed systems" /><category term="Distributed systems" /><summary type="html">Microservice design, monolith to microservice migration, distributed systems</summary></entry></feed>