<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Alex on Medium]]></title>
        <description><![CDATA[Stories by Alex on Medium]]></description>
        <link>https://medium.com/@la3mmchen?source=rss-a6a0c100e173------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*qlKWQ5hAPbo5cLIv_PuLSQ.jpeg</url>
            <title>Stories by Alex on Medium</title>
            <link>https://medium.com/@la3mmchen?source=rss-a6a0c100e173------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 05:39:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@la3mmchen/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How Prezi replaced a homegrown Log Management System with Grafana Loki]]></title>
            <link>https://medium.com/prezi-engineering/how-prezi-replaced-a-homegrown-log-management-system-with-grafana-loki-15111174ff91?source=rss-a6a0c100e173------2</link>
            <guid isPermaLink="false">https://medium.com/p/15111174ff91</guid>
            <category><![CDATA[logging]]></category>
            <category><![CDATA[sre]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[prezi]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Alex]]></dc:creator>
            <pubDate>Thu, 08 Feb 2024 15:26:37 GMT</pubDate>
            <atom:updated>2024-02-08T15:26:37.121Z</atom:updated>
            <content:encoded><![CDATA[<p>Prezi has quite a sophisticated engineering culture where solutions are built that do the job. Some solutions that have been built in the past stood out and aged well. In other areas, some solutions have lost traction compared to industry standards.</p><p>In the second half of 2023, we modernized one of those areas that was not market-standard anymore: the logfile management system of Prezi. This is our testimonial.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pmZClgRKPe7CZ0EI" /><figcaption>Photo by <a href="https://unsplash.com/@alvaroserrano?utm_source=medium&amp;utm_medium=referral">Álvaro Serrano</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>How it was before</h3><p>We traced the beginning of the existing solution back to 2014. So it is safe to say that it was a stable solution.</p><p>The following depicts the solution. Every workload Prezi ran was instrumented with a special sidecar that took care of handling all log messages. That sidecar was built on top of two open-source solutions: scribe (<a href="https://github.com/facebookarchive/scribe">https://github.com/facebookarchive/scribe</a>), a tool built by Facebook, archived on Github in 2022.<br>Scribe took care of receiving log events, aggregating them, and sending them downstream.</p><p>The second component, sTunnel (<a href="https://www.stunnel.org/">https://www.stunnel.org/</a>), took care of encrypted communication from the workload systems to the central system.</p><p>Prezi collected log events from all environments in one central place and made them accessible to engineers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6embu5Y5a8PlAbE6" /><figcaption>legacy log management system</figcaption></figure><p>Yes, the picture is telling the truth: the consumption of collected log events happened a good part of 2023 over SSH and not over any UI.</p><p>That alone was a fact to reimplement the whole solution and develop it with current market-best practices in mind. Our goal was to make the user experience more accessible and the query results better shareable.</p><h4>Logshipping</h4><p>With that in mind, we started the project’s first iteration. Our first take was to provide a central system that could aggregate and display log events in a more user-friendly way. Also, we wanted to get rid of the sidecar to ease operational load: while a sidecar per se is not a bad thing and a very battle-proven design pattern, it comes with certain costs when running thousands of pods.</p><p>The sidecar solution was born in times when Prezis workload ran on Elastic Beanstalk which means just an additional container on a probably oversized EC2 instance.</p><p>With the shift to <a href="https://kubernetes.io/">Kubernetes</a> as the workload engine the oversized EC2 instance vanished but the sidecar remained. Also, Kubernetes offers a very standardized way to consume logs from containers: stdout and stderr of the container are written to file on the Kubernetes worker hosts by the container runtime. And files can be easily consumed.</p><p>We did exactly that and used one of the established tools in that domain — filebeat — which is capable of reading the mentioned files and enriching the resulting events with metadata from Kubernetes — e.g. pod and container name and namespace.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kdRkH0zJRvSJmhWJ" /><figcaption>Details on the log shipping process</figcaption></figure><p>This was the first optimization. The second was how events will be sent to downstream systems.</p><p>Operating in cloud environments requires a fast shipping of events away from nodes as these nodes can vanish at any time.</p><p>A common design pattern for this is to use a message queue as the first persistent layer. This can protect downstream systems in case of event bursts. It also decouples the individual parts from each other which can be helpful for maintenance or even replacements of tools.</p><p>Most of the time, the message queue used for that is an <a href="https://kafka.apache.org/">Apache Kafka</a> installation that is capable of storing events at scale. As we already used a Kafka setup to store business events from multiple sources, we went that route without digging further into alternative persistent layers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8ObkuZnvyiNT9IKs" /><figcaption>Sending events to a message queue</figcaption></figure><p>Once the events are in the queue, they can be parsed and ingested into a central system.</p><h3>Parsing and Storing</h3><p>In our first take on this, we planned to set up the central log file management system inside our cloud environment. When doing that, there are 2 major options to go: do something with <a href="https://www.elastic.co/elasticsearch">Elasticsearch</a> or use <a href="https://grafana.com/oss/loki/">Grafana Loki</a> as the backend.</p><h3>The very first take</h3><p>We’ve started with <a href="https://aws.amazon.com/opensearch-service/">AWS OpenSearch</a> service as a backend and <a href="https://www.elastic.co/logstash">Logstash</a> to feed events from Kafka into our OpenSearch cluster.</p><p>As we run most of our software on Kubernetes, we also set up Logstash on Kubernetes and soon discovered all the joy of running a JVM inside containers. We suffered a lot of out-of-memory kills of that component.</p><p>Storing and indexing a massive amount of data into OpenSearch leads to massive indexes that soon have not been manageable anymore. This was caused by the vast amount of non-standardized fields in the application logging. A lot of heterogeneity in the fields and the contents leads to a lot of parsing errors. The most prominent example is the time and date format. Some applications have been logging unix timestamps, whereas others are using a string representation.</p><p>We discovered that if we don’t control the sources, a solution based on OpenSearch will not service us well. Going to control the source by evangelizing a common log scheme throughout all applications would have been the only way to make this work.</p><h3>The overhaul</h3><p>We started to look into an alternative to Logstash to get rid of the memory issues. We started to replace it with vector.dev which has a smaller footprint, a more flexible configuration, and it can also send to more possible backends. Logstash, without any modification, is tied closely to the OpenSearch ecosystem. But as spoiled above there is another major option to save log events: Grafana Loki.</p><p>With the replacement of Logstash, we got rid of the constant restart but not of the constant indexing errors.</p><p>Soon we started to look into Loki as an alternative. Also, we considered the hosting option as the running and maintenance of a log management system is not one of our core tasks. Running that system is more or less a commodity and takes away precious time that could be spent otherwise.</p><p>Focusing on our core tasks as the SRE team is also beneficial for customers of Prezi.</p><h3>Optimizing the central systems</h3><p>Looking at log management systems is in most cases also a buy or make (host) decision: Do one want to have the whole aggregation systems self-hosted or can this be offloaded to some 3rd party vendor?</p><p>Security and compliance concerns aside, this mostly boils down to the question of “How much can we spend?”.</p><p>With the security clearing to send logs to a 3rd party vendor and the budget to do so, we started to look at the hosted version of Loki. It turned out to be within our cost range and it can service us well: They had no issues with our ingestion rate. The way Loki stores log events as streams was perfect as it moved the problem Opensearch had with the variety of field contents from indexing time to later. With Loki, those differences surface at query time and can be tackled by predefined dashboards. This way we don’t lose any events by parsing errors.</p><p>The way to consume events that are stored in Loki is a very common user interface: Grafana, which is a well-known dashboarding solution and is already in use. With that, engineers can rely on existing tool knowledge.</p><p>Offloading logs to an external vendor also removes them from your direct control. To avoid any issues with any retention period, we also started to write logs additionally to S3 to archive them. That way, we have control over them and can use them in case we need them later.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PbXorBPK4zfXl1l1" /><figcaption>Details on parsing and storing</figcaption></figure><p>With that last piece in place, we have been able to shut down the above-mentioned original log management system at the end of 2023.</p><h3>The result</h3><p>Looking at the completely new log management system, we went from a very homegrown solution to a modern stack:</p><ul><li>We consume logs via a standard API of the container runtime</li><li>Sending the events to Kafka enables us to consume them decoupled from the creation time. Kafka also stores events for a certain period, so any downtime of downstream systems does not cause data loss.</li><li>Vector enables us to feed events into multiple sinks. Even though not outlined before, it enables us to make certain parsing and routing decisions when parsing events. But that is part of another story.</li><li>Loki enables us to consume event streams via the well-known Grafana UI and query a vast amount of data in real time.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nioxAbvHaC3AJLta" /><figcaption>The whole process</figcaption></figure><h3>Lessons learned</h3><p>The whole project took us most of a year until we shut down the old solution. We took this amount of time to verify all is well set up, all engineers are onboarded and familiar with the solution, and the solution is capable of handling all different peak situations.</p><ul><li>Keeping the old system running has been a good decision. By that, we have been able to optimize the new system until it was able to handle the load and satisfy our needs</li><li>Starting to advertise a common logging scheme through a company is beneficial. That scheme makes collecting and analyzing events simpler. It gives a better user experience, too, because a timestamp is always in the same format for example.</li><li>Controlling log levels and the understanding of the various log levels are also crucial. What one engineer sees as debug another emits as info. Creating a common understanding is helpful.</li><li>Decoupling the different components from one another enables us to change them if we have other requirements or find better solutions. E.g. if we start to get unhappy with Vector, we can replace it without any hassle as the interface between the log source and Vector is Kafka.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/894/1*FBFUJS8_X6pBw2BPL60RkA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=15111174ff91" width="1" height="1" alt=""><hr><p><a href="https://medium.com/prezi-engineering/how-prezi-replaced-a-homegrown-log-management-system-with-grafana-loki-15111174ff91">How Prezi replaced a homegrown Log Management System with Grafana Loki</a> was originally published in <a href="https://medium.com/prezi-engineering">Prezi Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Prezi Serves Customer Traffic]]></title>
            <link>https://medium.com/prezi-engineering/how-prezi-serves-customer-traffic-60fc9711702b?source=rss-a6a0c100e173------2</link>
            <guid isPermaLink="false">https://medium.com/p/60fc9711702b</guid>
            <dc:creator><![CDATA[Alex]]></dc:creator>
            <pubDate>Tue, 09 Jan 2024 09:56:32 GMT</pubDate>
            <atom:updated>2024-01-09T09:56:32.688Z</atom:updated>
            <content:encoded><![CDATA[<p>Prezi has a global audience that depends on the fast and reliable accessibility of its content. In this article, we look into the way Prezi serves content from a network perspective.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wAbH9ve3pibIrm0F" /><figcaption>Photo by <a href="https://unsplash.com/@dead____artist?utm_source=medium&amp;utm_medium=referral">Z</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>See this article as a general overview of how content can be served on a global scale. This is not the only and probably not the ultimate solution but one way to do it.</p><p>The overall flow of this is depicted in the following image. Prezi runs on AWS and uses AWS services to offer customer-facing internet endpoints.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*eddbE2b-YnTWyh9oNkoIeg.png" /><figcaption>Network diagram</figcaption></figure><p>The DNS zones and records are managed in Route53. Customer traffic goes through AWS Global Accelerator to decrease latency before it is filtered by AWS Web Application Firewall (WAF). The traffic is then terminated at the Application Load Balancer (ALB) and forwarded into the cloud environment where most of the workload runs inside Elastic Kubernetes Services (EKS).</p><p>Some of the customer traffic is going to AWS Cloudfront which is used to deliver media assets that benefit from being cached closer to the customer.</p><p>The following article will go over these components, see what they do, and discuss the benefits those components offer.</p><h3>Find the best path (AWS Route53 and Global Accelerator)</h3><p>Having customers worldwide and offering services over the Internet poses multiple challenges. One of them is to reduce latency. Cloudflare defines latency as the “amount of time it takes for a data packet to go from one place to another. Lowering latency is an important part of building a good user experience.” (source <a href="https://www.cloudflare.com/en-gb/learning/performance/glossary/what-is-latency/">https://www.cloudflare.com/en-gb/learning/performance/glossary/what-is-latency/</a>)</p><p>That said, the challenge in having customers worldwide is the heterogeneity of the network normal people call “the internet”.</p><p>When we look at the lower network layer at the internet topology, we can see many different networks peered together.</p><p>The following image shows parts of the peering connections in Latin America that form the internet’s backbone. For a data packet, going from South America to Miami means traversing through multiple networks and every network adds a little bit to the complete travel time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5spQvhNu27Ddsual" /><figcaption>taken from <a href="https://global-internet-map-2022.telegeography.com/">https://global-internet-map-2022.telegeography.com/</a></figcaption></figure><p>Going back to the challenge of controlling latency for customers there are generally speaking 2 options:</p><ul><li>Offering services close to the customer to avoid far network travels</li><li>Offer a fast path from the customer to the place where services are offered.</li></ul><h4>The best path for most of the world</h4><p>Prezi uses the second option by offering a fast path to services via AWS GlobalAccelerator. This service enables customer traffic to be routed most of the time via the global AWS network instead of the public internet.</p><p>This routing reduces latency. In experiments from my local machine, optimized requests traveled 200ms faster than the not-optimized ones. The total time until I got an answer went down from 800ms to 600ms. <br>Loading the Prezi dashboard when logged in needs at the moment roughly 150 individual requests which all benefit from the decrease of 25% in latency. <br>Please keep in mind that the real percentage of acceleration depends on multiple factors like location and current routing situation.</p><p>Whenever a customer sends requests to prezi.com, those requests are routed to the closest AWS network endpoint and then transferred inside this global network.</p><h4>And the best path for inhabitants of Virginia</h4><p>As stated in the headline of the previous chapter, most Prezi customers go to Global Accelerator except those who reside in Virginia. Those customers are already close enough to the service endpoint and are routed directly to the following components.</p><p><em>Note</em>: the network diagram above does not show this route to avoid being too complex.</p><h3>Implementation</h3><p>To achieve this, Prezi leverages geo-balanced DNS queries in Route53 so that different IP addresses are returned depending on the location.</p><p>The following screenshot for a practical example. The first lookup is executed from a local machine in Europe, and the second one with an activated VPN from Virginia.</p><p>The first DNS query returns the endpoints for the Global Accelerator, and the second query from Virgina returns the endpoints of some AWS load balancer (see the following chapter).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*er-snPt_ZVhdB3Xf" /><figcaption>Terminal showing different DNS lookup results depending on location.</figcaption></figure><h4>Alternatives</h4><p>The alternative to this network-based approach is to move offered services closer to the customer. This can be achieved for example by deploying instances into selected cloud regions. To achieve this, the whole application stack needs to be deployed and some backend synchronization is needed — as part of the Prezi, suite enables collaboration in-between multiple users.</p><p>Serving from a single region reduces the complexity and streamlines deployment.</p><h3>Protection (AWS WAF and Shield)</h3><p>While the internet is a wonderful place to connect, collaborate, be creative, and a lot more, it is at the same time also a place that attracts bad actors. It is widespread that public and well-known endpoints are the target of distributed denial of service (DDoS) attacks. Prezi leverages the combination of AWS Web Application Firewall (WAF) and Shield to protect the downstream infrastructure from these threat vectors.</p><p>Every request that needs to reach Prezi infrastructure is evaluated through these components. Certain endpoints are protected via a specific rate limit to make sure they are not hammered.</p><p>For example, it does not make sense to send multiple requests for the login endpoint within a small amount of time. To protect sensible endpoints, the AWS WAF can respond with HTTP/429 (<a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429">https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429</a>). <br>See the following screenshot of how a triggered rate limit looks in the browser console:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wRfL6hOiUq5NUAKw" /><figcaption>Chrome Developer tools show one HTTP response</figcaption></figure><p>On a bigger scale, the traffic flow is monitored by AWS Shield and blocked when a DDoS attack is detected. When Shield detects a DDoS from multiple traffic sources, those sources get blocked.</p><h4>Alternatives</h4><p>Offering services over the Internet without any protection is a bad idea. Any public-facing IP is attracting traffic and if a company has reached a certain scale it attracts bad actors. There are alternative solutions and vendors like Cloudflare or Akamai that can offer the same protection service. As we run our workload on AWS the natural choice is AWS WAF as the integration is easy.</p><h3>Access (ALB, EKS, API Gateway)</h3><p>Requests allowed to enter reach the AWS-managed load balancer fleet that keeps track of routing those requests into the VPC environment that hosts the actual workload. The load balancer uses our public TLS certificate to offload HTTPS connections from customers.</p><p>The application load balancer (ALB) is used for routing based on the HTTP Host header. This means that based on the domain used, ALB can forward traffic into the isolated workload environment.</p><p>Running inside the Kubernetes fleet is a self-written API gateway. The purpose of this component is to build more detailed routes based on request paths or other identifiers. Most of the backends are based on Python and Scala. Those pods run inside the Kubernetes offering of AWS: Elastic Kubernetes Service. <br>Traffic is routed into these pods either by a WSGI conform application server in Python land or directly by the JVM for Scala services.</p><p>As the mentioned API gateway runs also inside Kubernetes, it can forward traffic to the target backend services based on different routing guidelines within the cluster network. The API gateway offers the flexibility to do advanced routing to the microservices based on configuration by the developers.</p><p>When you think back about the scope of AWS WAF usage, there was no check for malicious content and requests. We use a different web application firewall to check for bad requests and protection against cross-site scripting, injections, and other things that might harm Prezi — or our customer.</p><h3>Content delivery (CloudFront)</h3><p>Prezi’s main purpose is to deliver amazing presentations that most of the time contain visuals like images and gifs. They can be served via a content delivery network (CDN) that can reproach content closer to the customer.</p><p>Loading resources from a CDN does decrease the time in which the user waits for the resources to appear.</p><p>Also on the cost focus, it is cheaper to serve content from CloudFront instead of serving it every time from the backend. This applies especially to assets like images that don’t change often.</p><p>Due to the deep integration into the ecosystem, in our setup, there is no other choice than CloudFront. Technically, it should also be doable with CloudFlare or any other CDN vendor.</p><h3>Wrap up</h3><p>The article above describes the architecture Prezi uses to serve content to a global audience.</p><p>There are multiple different ways to serve traffic — even if running on AWS.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=60fc9711702b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/prezi-engineering/how-prezi-serves-customer-traffic-60fc9711702b">How Prezi Serves Customer Traffic</a> was originally published in <a href="https://medium.com/prezi-engineering">Prezi Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Keep the databases top-notch]]></title>
            <link>https://medium.com/prezi-engineering/keep-the-databases-top-notch-96b2d004e1cf?source=rss-a6a0c100e173------2</link>
            <guid isPermaLink="false">https://medium.com/p/96b2d004e1cf</guid>
            <category><![CDATA[blue-green-deployment]]></category>
            <category><![CDATA[rds]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Alex]]></dc:creator>
            <pubDate>Tue, 09 May 2023 12:58:13 GMT</pubDate>
            <atom:updated>2023-05-09T12:58:13.278Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JA0F7dKbF1y3Cc6T" /><figcaption>Photo by <a href="https://unsplash.com/@thisisengineering?utm_source=medium&amp;utm_medium=referral">ThisisEngineering RAEng</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Databases are often the most critical parts of applications. Prezi is no exception to this. <br>We store and read persistent data from many different databases while serving requests from our users.</p><p>There is often some hesitation when it comes to updating databases. Taking down databases for maintenance usually takes down the services that use them.</p><p>Early this year, the SRE team started to work on the maintenance task for our AWS RDS MySQL instances. We started looking at our options.</p><h3>The “maintenance window” approach</h3><p>A very classical approach is to define a maintenance window and do the necessary actions within this window. This works but is not a very user-friendly approach. It is even worse if one operates at a global scale from a central infrastructure: which user do you want to hit with the downtime?</p><p>A benefit of this approach is that you create a clear state in the database before the action by disabling all writing operations at the beginning. In case the application can serve only read-only traffic, it is also possible to offer a read-only instance during the maintenance window.</p><p>As we looked into the services that would be affected by our maintenance, we discovered that two services within the critical path of our user experience were affected. Declaring a maintenance window and shutting down the service would have been a major degradation of our offered service.</p><p>We ran tests on snapshots of those instances and concluded that we would need a downtime of roughly 1 hour to be finished.</p><p>We said: this is only the way to go if we find nothing else.</p><h3>The “poor man’s blue/green” approach</h3><p>There are some strategies that can help to hide most of the downtime from your users. It is possible to access a database through a load balancer that is able to forward traffic only to a specific instance.</p><p>It is also possible to use a primary/secondary setup where you can promote an already patched instance to become the new primary instance.</p><p>Most of the time, the challenge in this approach is the synchronization between the instances — just to name some: transactions, foreign keys, and network latency between the different systems that can make transactions tedious.</p><p>And this design pattern must be incorporated from the beginning. Changing the setup from connecting to a single instance to an advanced setup needs downtime too.</p><p>Another downside of this approach is: You have to pay for both instances.</p><p>For our case, this approach wasn’t the way to go as we didn’t build most of our databases in such a design.</p><h3>Enter: AWS RDS Blue/Green deployment</h3><p>AWS introduced <a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/blue-green-deployments-overview.html">blue/green deployment</a> at the Re:Invent late in 2022. There is this overlay at the top of the RDS console that keeps coming up and tells you to try blue/green deployment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oD1p4nvu75r6bibhhYpyTA.png" /><figcaption>AWS Console</figcaption></figure><p>Blue/Green offers the possibility to create a database cluster on the fly from a primary instance (blue). The newly created instance (green) can be updated without affecting the primary instance. There is a logical sync from blue to green. Under the hood, AWS RDS creates a MySql replication that syncs contents from the blue environment to the green one.</p><p>The initial creation of the blue/green setup is transparent for the applications that use the database. So you can set up all the things without affecting your users.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-pylloK1Hf-t_qF1sl8YIg.png" /><figcaption>A configured Blue/Green deployment</figcaption></figure><p>Once ready and running, the connections can be switched over from blue to green with a short downtime of approximately 1 minute.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/652/1*YALoTG-bsM3tTc5Toc7y1Q.png" /><figcaption>Switchover summary</figcaption></figure><p>After successfully switching traffic from the blue to the green database, the old instance is retained. It can serve as a fallback if the new instance is somehow broken. Once confident that nothing was broken, it can be removed. So you only have to run 2 databases at a time for the time of maintenance tasks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*LrWnoPMiU0t3Ui0bWedZsA.png" /><figcaption>Ex-Blue/Green deployment</figcaption></figure><p>In the past 4 weeks, we used this approach for updating roughly 30 databases to the latest MySQL minor version. It worked like a charm. Even for our most critical databases, we were able to reduce the downtime to approximately 3 minutes.</p><p>Things we learned during that process:</p><ul><li>There is no way back after you’ve triggered the switchover process. After moving the traffic over from blue to green, you’ll end up with two independent instances that are no longer in sync. The replication in between is gone.<br>Your old instance even has a new VPC endpoint. There is no way to sync those databases again. <br>This means: If you need the old instance again, a possible rollback can be a re-deployment of the application with a config that uses the old instance again.</li><li>Doing downtime-free database upgrades manually is a tedious, complex, and error-prone process. It involves a lot of clicking and a lot of waiting. It would be better to automate the steps.</li><li>Take care that you select the correct MySQL parameter group while setting up your blue/green deployment. You can’t change this on the green instance afterward. It cost us some time to rebuild the blue/green deployment.</li><li>Always do a manual and fresh snapshot before any actions. Even though we did not need it, it makes you more confident if you have a clear state to go back to.</li></ul><h3>Conclusion</h3><p>The blue/green deployment makes database updates easy and very user-friendly.</p><p>The next step is building automation scripts around this, which prepare everything up to the point of the switchover. This will make the process less error-prone and it will require less engineer time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=96b2d004e1cf" width="1" height="1" alt=""><hr><p><a href="https://medium.com/prezi-engineering/keep-the-databases-top-notch-96b2d004e1cf">Keep the databases top-notch</a> was originally published in <a href="https://medium.com/prezi-engineering">Prezi Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>