<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Re Alvarez-Parmar</title>
    <description>The latest articles on DEV Community by Re Alvarez-Parmar (@realz).</description>
    <link>https://dev.to/realz</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F835059%2F7f338fad-0ebf-4d4b-8877-afbccc34e341.png</url>
      <title>DEV Community: Re Alvarez-Parmar</title>
      <link>https://dev.to/realz</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/realz"/>
    <language>en</language>
    <item>
      <title>Closing observability gaps with custom metrics</title>
      <dc:creator>Re Alvarez-Parmar</dc:creator>
      <pubDate>Sun, 29 May 2022 07:01:46 +0000</pubDate>
      <link>https://dev.to/realz/closing-observability-gaps-with-custom-metrics-2m5c</link>
      <guid>https://dev.to/realz/closing-observability-gaps-with-custom-metrics-2m5c</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Which application metrics should you collect?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I frequently engage with customers that are amid breaking their monolithic applications into smaller microservices. Many teams with also see this migration as an opportunity to make applications more observable. As a result, customers inquire which metrics they should monitor for a typical cloud native application.&lt;/p&gt;

&lt;p&gt;Previously, when a customer asked me how to instrument a service, I pointed them to the well known &lt;a href="https://grafana.com/blog/2018/08/02/the-red-method-how-to-instrument-your-services/"&gt;USE and RED methods&lt;/a&gt;. But, I felt the response wasn’t thorough. A list of specific metrics to monitor can be helpful for teams building cloud native applications. This post is an attempt to provide a list of metrics to collect in a typical application. Not all the metrics listed below apply to every application type. For example, batch-like workloads rarely serve traffic, and resultantly, don't need to keep a log of requests-served.&lt;/p&gt;

&lt;p&gt;The goal of this document is to help developers come up with the golden signals for their applications.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Golden Signals, a term used first in the &lt;a href="https://sre.google/sre-book/monitoring-distributed-systems/"&gt;Google SRE handbook&lt;/a&gt;. Golden Signals are four metrics that will give you a very good idea of the real health and performance of your application as seen by the actors interacting with that service, whether they are final users or another service in your microservice application.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Observability
&lt;/h2&gt;

&lt;p&gt;Cloud best practices recommend building systems that are observable. While the word observability (or “/O11y/” as it is popularly known) doesn’t have an official definition, it is the measure of a system’s ability to expose its internal state. The three pillars of observability are logs, metrics, and traces.&lt;/p&gt;

&lt;p&gt;Modern systems are designed to produce logs, /emit/ metrics, and provide traces to help developers and operators understand its internal state.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://giedrius.blog/2019/05/11/push-vs-pull-in-monitoring-systems/"&gt;Push vs Pull&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Emitting metrics by exposing them on an externally accessible HTTP endpoint is gaining wider adoption thanks to developers adopting Prometheus for monitoring. In this model, Prometheus pulls metrics by scraping the application’s &lt;code&gt;/metrics&lt;/code&gt; endpoint.&lt;/p&gt;

&lt;p&gt;When you run Node Exporter, it publishes metrics at &lt;code&gt;http://localhost:9100/metrics&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Observability tools aggregate and analyze data from different sources to help you detect issues and identify bottlenecks. The goal is to use these system signals to improve its reliability and prevent downtime.&lt;/p&gt;

&lt;p&gt;AIOps products like &lt;a href="https://aws.amazon.com/devops-guru/"&gt;Amazon DevOps Guru&lt;/a&gt; can also detect anomalies using your application's logs, metrics, and traces (and other sources) and give you early signals to prevent a potential disruption.&lt;/p&gt;

&lt;h2&gt;
  
  
  Metrics to collect
&lt;/h2&gt;

&lt;p&gt;For an application to function as designed, the application and its underlying system have to be /healthy/. Host metrics inform the operator of the host’s and infrastructure resource usage, like CPU, memory, I/O, etc. If you use Prometheus, &lt;a href="https://github.com/prometheus/node_exporter"&gt;Node Exporter&lt;/a&gt; collects this information automatically for you.&lt;/p&gt;

&lt;p&gt;Host metrics rarely differ. Whether we run a process on an EC2 instance or a Raspberry Pi, we’re interested in the same metrics.&lt;/p&gt;

&lt;p&gt;Unlike host metrics, application metrics are unique to each microservice. Application metrics are supposed to provide the operator the information so they can do these things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Identify future areas of improvement by providing code-specific measurements. Application monitoring or APM tools provide measurements over a segment of time that developers can analyze.&lt;/li&gt;
&lt;li&gt;When the system fails, provide information for troubleshooting and prevention.&lt;/li&gt;
&lt;li&gt;In some cases, provide early signals to business. For example, if the application exposes, the /orders/ it has processed in the last 60 minutes can be tracked using the monitoring system, rather than querying a relational database.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;There are several companies like application monitoring or APM companies like New Relic, DataDog that have products to aggregate application metrics using SDKs or agents. However, what they will not collect are the business specific metrics that only your application cares about.&lt;/p&gt;

&lt;p&gt;In order to create a list of relevant metrics for an application, its architects will need to determine a signal for its every key function. The hallmark of a microservice is that it does /one thing well/, therefore it shouldn’t have many key functions. Start by white-boarding the functions implemented in the code and creating a list of metrics that would help you gauge its performance (or its availability at the least).&lt;/p&gt;

&lt;p&gt;Most measurements you’ll do will fall under one of these categories:&lt;/p&gt;

&lt;h3&gt;
  
  
  Counter
&lt;/h3&gt;

&lt;p&gt;As the name suggests, this value is incremented when a function runs. Example: total requests served&lt;/p&gt;

&lt;h3&gt;
  
  
  Histogram
&lt;/h3&gt;

&lt;p&gt;Histograms are charts that show the frequency of the occurrence of several ranges of values. A histogram samples observations (usually things like request durations or response sizes) and counts them in configurable buckets.&lt;/p&gt;

&lt;h3&gt;
  
  
  Gauge
&lt;/h3&gt;

&lt;p&gt;This type is metric tracks a value that increases or decreases over a period. Example: number of threads.&lt;/p&gt;




&lt;p&gt;With that background, let’s go through the list of common custom metrics developers use.&lt;/p&gt;

&lt;h3&gt;
  
  
  Network activity
&lt;/h3&gt;

&lt;p&gt;These are the obvious metrics to track for any application that serves traffic. Network metrics tell you how much load is placed on the system. Over the time, these data points assist you when devising the scaling strategy for the system.&lt;/p&gt;

&lt;p&gt;Things you should include are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Request count by API type or page&lt;/li&gt;
&lt;li&gt;Requests total&lt;/li&gt;
&lt;li&gt;Transactions&lt;/li&gt;
&lt;li&gt;Concurrent, expired, and rejected sessions&lt;/li&gt;
&lt;li&gt;A watermark that records maximum concurrent sessions&lt;/li&gt;
&lt;li&gt;Average processing time&lt;/li&gt;
&lt;li&gt;A count by error type&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Resource usage
&lt;/h3&gt;

&lt;p&gt;It is a best practice to monitor a systems /saturation/, which is a measure of your systems resource consumption. Every resource has a /breaking point/, beyond which additional stress causes performance degradation. Scalable and reliable systems are designed to never breach the breaking point.&lt;/p&gt;

&lt;p&gt;However, simply collecting overall resource saturation at an application level is insufficient. You also need to look deeper at thread or resource pool level.&lt;/p&gt;

&lt;p&gt;Consider collecting these metrics:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Number of processors, system CPU load, process CPU load, available memory, used memory, available swap, used swap, open file descriptor count.&lt;/li&gt;
&lt;li&gt;Total resources consumed by connection pools, thread pools, and any other resource pools.&lt;/li&gt;
&lt;li&gt;Total started thread count, current thread count, current busy threads, keep alive count, poller thread count, and connection count.&lt;/li&gt;
&lt;li&gt;Objects created, destroyed, and checked out, high-water mark, number of times checked out,&lt;/li&gt;
&lt;li&gt;Number of threads blocked waiting for a resource, number of times a thread has blocked waiting&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Common frameworks like Tomcat, Flask, etc. support exporting pre-defined metrics. For example, JMX already exposes a bunch of these metrics. See &lt;a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/ContainerInsights-Prometheus-Sample-Workloads-javajmx.html"&gt;AWS CloudWatch documentation&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Users
&lt;/h3&gt;

&lt;p&gt;Besides, serving the intended audience, bots or scripts flood internet facing web servers with requests. These automated requests can overload the system if unauthenticated requests are improperly handled (for example, not redirecting all unauthenticated requests to the authentication service and attempting to process an unauthenticated request).&lt;/p&gt;

&lt;p&gt;Here are user related metrics to collect:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Authenticated and unauthenticated requests&lt;/li&gt;
&lt;li&gt;Demographics, authenticated and unauthenticated requests, usage patterns,&lt;/li&gt;
&lt;li&gt;Unsuccessful login attempts&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Some of these metrics may also come from your Load Balancer or ingress.&lt;/p&gt;

&lt;h3&gt;
  
  
  Business transaction (for each type)
&lt;/h3&gt;

&lt;p&gt;If your application follows the microservices approach, then the code fulfills one function, at least that’s the idea. What are the key performance indicators for your app’s function? Define them and track these metrics.&lt;/p&gt;

&lt;p&gt;Should future releases cause performance regression, you’ll be able to detect it. Tracking these business metrics will help you track trends easily and avoid a cascading failure.&lt;/p&gt;

&lt;p&gt;Here are common things that services care about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Orders, messages, requests, transactions processed&lt;/li&gt;
&lt;li&gt;Success and failure rates. For a retailer, this could be the conversion rate.&lt;/li&gt;
&lt;li&gt;Service level agreements (like average transaction response time)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you still need help with identifying key metrics, ask yourself this question: In what ways can my application negatively affect the business even when it might appear to be healthy?&lt;/p&gt;

&lt;h3&gt;
  
  
  Database connections
&lt;/h3&gt;

&lt;p&gt;Along with monitoring your database instances using database monitoring tools, consider collecting database connection health metrics in your application. This is especially helpful if your application uses a shared database. If your application encounters database connection errors but the database remains operational for other application, you know the problem is on the application side, and not the database.&lt;/p&gt;

&lt;p&gt;Consider recording these databases-related metrics:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A count of &lt;code&gt;SQLException&lt;/code&gt; thrown&lt;/li&gt;
&lt;li&gt;Number of (concurrent or maximum)queries&lt;/li&gt;
&lt;li&gt;Average query run time&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Data consumption
&lt;/h3&gt;

&lt;p&gt;Wherever you’re persisting data, you need to ensure that you’re going to go over your quotas and run out of space. Besides, monitoring on disk and in-memory data volumes, don’t forget to monitor the data your application stores in databases and caches.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cache health
&lt;/h3&gt;

&lt;p&gt;Speaking of cache, it is a best practice to monitor these metrics:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Items in cache&lt;/li&gt;
&lt;li&gt;Get and set latency&lt;/li&gt;
&lt;li&gt;Hits and miss rates&lt;/li&gt;
&lt;li&gt;Items flushed&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Also, consider using an external cache such as Redis or Memcached.&lt;/p&gt;

&lt;h3&gt;
  
  
  External services
&lt;/h3&gt;

&lt;p&gt;Keeping a track of how downstream services perform is also useful in understanding issues. Along with using timeouts, retries (preferably with &lt;a href="https://en.wikipedia.org/wiki/Exponential_backoff"&gt;exponential backoff&lt;/a&gt;), and circuit breakers, consider monitoring these metrics for every external service your service's proper functioning depends on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Circuit breaker status&lt;/li&gt;
&lt;li&gt;Count of timeouts, requests&lt;/li&gt;
&lt;li&gt;Average response time or latency&lt;/li&gt;
&lt;li&gt;Responses by type&lt;/li&gt;
&lt;li&gt;Network errors, protocol errors&lt;/li&gt;
&lt;li&gt;Requests in flight&lt;/li&gt;
&lt;li&gt;A high watermark of concurrent requests.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Granularity in metrics collection
&lt;/h3&gt;

&lt;p&gt;The frequency at which you publish and collect metrics depends on your business requirements. For a retailer, knowing traffic patterns by the hour and day is useful in scaling capacity. Similarly, a travel company’s traffic pattern are influenced by holiday schedules.&lt;/p&gt;

&lt;p&gt;Amazon EC2 provides instance metrics at 1-minute interval, which is a good start for critical metrics.&lt;/p&gt;

&lt;p&gt;Remember that there’s a cost attached to exposing, collecting, and analyzing metrics. Collecting unnecessary information in metrics can put a strain on the system and slow down troubleshooting.&lt;/p&gt;

&lt;p&gt;Consider giving the operator the control over the metrics your code should generate. This way, you can turn on specific metrics whenever needed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Finding out which metrics to collect is an answer that only the most familiar with the code can answer. This post provides a list of metrics for you to get started.&lt;/p&gt;

&lt;p&gt;Are there any metrics that I have overlooked? Let me know at &lt;a href="https://twitter.com/realz"&gt;@realz&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://giedrius.blog/2019/05/11/push-vs-pull-in-monitoring-systems/"&gt;Push Vs. Pull In Monitoring Systems – Giedrius Statkevičius&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.splunk.com/en_us/blog/learn/sre-metrics-four-golden-signals-of-monitoring.html"&gt;SRE Metrics: Four Golden Signals of Monitoring&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.oreilly.com/library/view/learning-modern-linux/9781098108939/"&gt;Learning Modern Linux&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.oreilly.com/library/view/release-it/9781680500264/"&gt;Release It!&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Appendix
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Instrumentation
&lt;/h3&gt;

&lt;p&gt;Instrumentation is the way to measure an application’s performance. It is highly useful in profiling and troubleshooting. There are two common strategies for instrumentation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Auto instrumentation. This is generally done using a library like OpenTelemetry API and SDK. For more see “&lt;a href="https://www.honeycomb.io/blog/what-is-auto-instrumentation/"&gt;What Is Auto-Instrumentation?&lt;/a&gt;”.&lt;/li&gt;
&lt;li&gt;Custom instrumentation. Whenever your instrumentation needs are not met by auto instrumentation, you will also generate custom metrics.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>observability</category>
      <category>microservices</category>
      <category>programming</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Connecting Kubernetes clusters across VPCs</title>
      <dc:creator>Re Alvarez-Parmar</dc:creator>
      <pubDate>Thu, 31 Mar 2022 22:41:11 +0000</pubDate>
      <link>https://dev.to/realz/connecting-kubernetes-clusters-across-vpcs-23ab</link>
      <guid>https://dev.to/realz/connecting-kubernetes-clusters-across-vpcs-23ab</guid>
      <description>&lt;p&gt;A few months ago, someone asked me the best way to &lt;strong&gt;connect services running in different Amazon EKS (EKS) clusters running in two different VPCs&lt;/strong&gt;. Thinking about connecting network resources across AWS VPCs reminded me of the early days of AWS when you needed to implement a &lt;a href="https://docs.aws.amazon.com/whitepapers/latest/building-scalable-secure-multi-vpc-network-infrastructure/transit-vpc-solution.html"&gt;complex hub and spoke architecture&lt;/a&gt; to connect Amazon Virtual Private Networking (VPC). Thankfully, AWS has newer services that simplify VPC interconnectivity.&lt;/p&gt;

&lt;p&gt;AWS customers can connect networked resources in different AWS accounts using VPC peering, AWS Transit Gateway, VPC sharing, AWS PrivateLink, or 3rd-party solutions.&lt;/p&gt;

&lt;p&gt;Given that there are so many options, I wasn’t sure which solution to recommend. The question I was posed needed a better understanding of AWS networking services. Here’s the research I did to understand the most optimal approach for connecting Kubernetes hosted services running in separate VPCs. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: I am not an AWS networking expert. This post was distilled from AWS documentation and this AWS &lt;a href="https://d1.awsstatic.com/whitepapers/building-a-scalable-and-secure-multi-vpc-aws-network-infrastructure.pdf"&gt;whitepaper&lt;/a&gt;.&lt;/em&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  Symmetric and Asymmetric flow
&lt;/h2&gt;

&lt;p&gt;Before picking a solution to interconnect services across different VPCs, you must consider your data connection requirements. There are two types of connectivity patterns between a set of network resources. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9yXR_mHV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.craft.do/user/full/9d54cc03-adfe-f72f-3389-565eb7356d1d/doc/E750C457-EBD6-4BC9-B64B-82503E319F6A/26D185BC-AFBB-490F-9A24-80F677B36EF4_2/t8Hbez8lyX1cCCxTTCM6wF43cfHyM0X9KJh7YwMBgoMz/Image.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9yXR_mHV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.craft.do/user/full/9d54cc03-adfe-f72f-3389-565eb7356d1d/doc/E750C457-EBD6-4BC9-B64B-82503E319F6A/26D185BC-AFBB-490F-9A24-80F677B36EF4_2/t8Hbez8lyX1cCCxTTCM6wF43cfHyM0X9KJh7YwMBgoMz/Image.png" alt="image" width="375" height="332"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the first scenario, &lt;em&gt;a client&lt;/em&gt; initiates a connection with the &lt;em&gt;server&lt;/em&gt; to* *send requests, but the server never initiates a connection with the client. A typical example will be a traditional three-tier web app that stores data in a database. In such a scenario, the backend connects to the database. The database never establishes a connection with the backend. I will call this type of connection flow as asymmetric flow in this blog.&lt;/p&gt;

&lt;p&gt;Symmetric flow is the opposite. In this data connectivity pattern, either side (client or server) can initiate a connection. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YAfyc5Wn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.craft.do/user/full/9d54cc03-adfe-f72f-3389-565eb7356d1d/doc/E750C457-EBD6-4BC9-B64B-82503E319F6A/ED6FF915-D47F-42E7-A618-590BED86B0E8_2/J0TrtZ5Tq6mYVcwIidOYTMzSPr8jW2k1wsdve1vlLg8z/Image.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YAfyc5Wn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.craft.do/user/full/9d54cc03-adfe-f72f-3389-565eb7356d1d/doc/E750C457-EBD6-4BC9-B64B-82503E319F6A/ED6FF915-D47F-42E7-A618-590BED86B0E8_2/J0TrtZ5Tq6mYVcwIidOYTMzSPr8jW2k1wsdve1vlLg8z/Image.jpeg" alt="image" width="816" height="534"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Customers looking to connect Kubernetes-hosted applications running in different AWS accounts will have to start by determining the data connection patterns their applications and services will use.&lt;/p&gt;

&lt;h2&gt;
  
  
  Connecting services hosted in different AWS accounts
&lt;/h2&gt;

&lt;p&gt;The type of connectivity your services require influences how you can connect services in different VPCs. &lt;/p&gt;

&lt;p&gt;When interconnecting private services that need symmetric flow, any service has to be able to initiate a connection with another service. Service discovery is a prerequisite for connectivity. Services have to know how to connect to downstream services. Once that problem is resolved (using DNS, or &lt;a href="https://www.consul.io"&gt;Consul&lt;/a&gt; etc.), there are two primary ways to interconnect services:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;VPC Peering (including TGW) or VPC Sharing&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;AWS PrivateLink&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The key difference between the two approaches is that once VPC peering or VPC sharing is set up,  network resources (EC2 instances, pods, containers) in the VPCs can interconnect by default.&lt;/p&gt;

&lt;p&gt;AWS PrivateLink provides secure access to services hosted in other VPCs without peering or sharing VPCs. You do this by configuring an interface endpoint to access the service in the other VPC. Because access control is more fine-grained, you may have to create an interface endpoint powered by PrivateLink for each Kubernetes hosted service that uses a different NLB.&lt;/p&gt;

&lt;p&gt;In the fullness of time, most large enterprises will  (many already do) use a combination of AWS networking services depending on the use case. In the next section, we review AWS network services and determine the scenarios in which they are a good fit. &lt;/p&gt;

&lt;h2&gt;
  
  
  🛟VPC Peering
&lt;/h2&gt;

&lt;p&gt;When services have to consume other services running in different VPCs, requiring symmetric flow, VPC peering is the easiest way to provide interconnectivity. &lt;/p&gt;

&lt;p&gt;You can connect the VPCs in which your EKS clusters reside as long as you had the foresight and luxury of pre-planning VPC CIDRs in advance (notice the intentional redundancy 🙂), and don’t have too many VPCs to interconnect or require t&lt;a href="https://docs.aws.amazon.com/vpc/latest/peering/invalid-peering-configurations.html"&gt;ransitive routing.&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KDcV1RBa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.craft.do/user/full/9d54cc03-adfe-f72f-3389-565eb7356d1d/doc/25063015-13A1-4BB7-AC8F-051C459295D9/39E98556-BFFC-4525-9B76-2B713E343C7A_2/onLV8rNs9U51ivwwKcdi6iz41iXA4NqptvEuDSMpHvgz/Image.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KDcV1RBa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.craft.do/user/full/9d54cc03-adfe-f72f-3389-565eb7356d1d/doc/25063015-13A1-4BB7-AC8F-051C459295D9/39E98556-BFFC-4525-9B76-2B713E343C7A_2/onLV8rNs9U51ivwwKcdi6iz41iXA4NqptvEuDSMpHvgz/Image.png" alt="image" width="880" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;VPC peering is the &lt;strong&gt;preferred method to connect VPCs when there are less than 10 VPCs&lt;/strong&gt; (&lt;a href="https://d1.awsstatic.com/whitepapers/building-a-scalable-and-secure-multi-vpc-aws-network-infrastructure.pdf"&gt;source&lt;/a&gt;). However, most enterprises have complicated, extensive networks and sub-networks, which inevitably leads to hundreds of VPCs. Interconnecting them using VPC peering is a difficulty that AWS Transit Gateway intends to solve. &lt;/p&gt;

&lt;h2&gt;
  
  
  🚉 AWS Transit Gateway
&lt;/h2&gt;

&lt;p&gt;AWS Transit Gateway (TGW) is another option to connect VPCs wherever services need to interconnect with symmetric flow. &lt;/p&gt;

&lt;p&gt;TGW is designed to simplify creating and managing multiple VPC peering connections at scale. It can act as the central router for large-scale, enterprise-grade, globally-distributed networks. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jtxeFUqY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.craft.do/user/full/9d54cc03-adfe-f72f-3389-565eb7356d1d/doc/38C9E4B8-323B-4856-9E79-E3EE1640D56E/7993907D-6527-40B4-BF67-B1C61956DD72_2/1xOZPjeTz8BzcHJKya1x7nGLk0rferbjZx7jkZ4viRMz/Image.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jtxeFUqY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.craft.do/user/full/9d54cc03-adfe-f72f-3389-565eb7356d1d/doc/38C9E4B8-323B-4856-9E79-E3EE1640D56E/7993907D-6527-40B4-BF67-B1C61956DD72_2/1xOZPjeTz8BzcHJKya1x7nGLk0rferbjZx7jkZ4viRMz/Image.jpeg" alt="image" width="880" height="510"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;TGW is the default choice for EKS users that have to connect their clusters with more than 10 VPCs and need symmetric flow. &lt;/p&gt;

&lt;h3&gt;
  
  
  Are there reasons for not using TGW?
&lt;/h3&gt;

&lt;p&gt;The good ole’ VPC peering still has some tricks up its sleeve that TGW hasn’t mastered yet. Here are a few reasons TGW may not be the right choice for you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Lower cost&lt;/strong&gt; — With VPC peering you only pay for data transfer charges. Transit Gateway has an hourly charge per attachment in addition to the data transfer fees. For example, in US-East-1:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EqjnwafT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.craft.do/user/full/9d54cc03-adfe-f72f-3389-565eb7356d1d/doc/38C9E4B8-323B-4856-9E79-E3EE1640D56E/F2F068F9-BEAD-480F-BC56-EEA9AC20C60A_2/BvP5LauYje7j6GXlnqYCNkGWwn1erFhidpxQyu3DpC8z/Image.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EqjnwafT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.craft.do/user/full/9d54cc03-adfe-f72f-3389-565eb7356d1d/doc/38C9E4B8-323B-4856-9E79-E3EE1640D56E/F2F068F9-BEAD-480F-BC56-EEA9AC20C60A_2/BvP5LauYje7j6GXlnqYCNkGWwn1erFhidpxQyu3DpC8z/Image.jpeg" alt="image" width="880" height="283"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;No bandwidth limits&lt;/strong&gt; - With Transit Gateway, Maximum bandwidth (burst) per Availability Zone per VPC connection is 50 Gbps. VPC peering has no aggregate bandwidth. Individual instance network performance limits and flow limits (10 Gbps within a placement group and 5 Gbps otherwise) apply to both options. Only VPC peering supports placement groups.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Latency -&lt;/strong&gt; Unlike VPC peering, Transit Gateway is an additional hop between VPCs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Security Groups compatibility -&lt;/strong&gt; Security groups referencing works with intra-Region VPC peering.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;TGW (or VPC Peering) enables inter-region VPC peering, which is helpful when your EKS clusters reside in different AWS regions. &lt;/p&gt;

&lt;h3&gt;
  
  
  🫱🏽‍🫲🏼Amazon VPC Sharing
&lt;/h3&gt;

&lt;p&gt;Here’s a third way to provide symmetric flow: share a VPC with multiple AWS accounts. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://aws.amazon.com/ram/"&gt;AWS Resource Access Manager&lt;/a&gt; (RAM) allows you to share VPCs (among other things) with other AWS accounts within your AWS Organization. &lt;/p&gt;

&lt;p&gt;RAM allows network administrators to create and manage VPCs centrally. Shared VPC enables network resources in different AWS accounts to communicate seamlessly as if they were on the same VPC and account. You can still control traffic using security groups and network ACLs. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You can share your VPCs to leverage the implicit routing within a VPC for applications that require a high degree of interconnectivity and are within the same trust boundaries. This reduces the number of VPCs that you create and manage while using separate accounts for billing and access control.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;VPC sharing benefits:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Simplified design — no complexity around inter-VPC connectivity&lt;/li&gt;
&lt;li&gt;Fewer managed VPCs&lt;/li&gt;
&lt;li&gt;Segregation of duties between network teams and application owners&lt;/li&gt;
&lt;li&gt;Better IPv4 address utilization&lt;/li&gt;
&lt;li&gt;Lower costs — no data transfer charges between instances belonging to different accounts within the same Availability Zone&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;According to the whitepaper, customers can use VPC sharing in conjunction with TGW to optimize for cost and performance. VPC sharing has a few &lt;a href="https://docs.aws.amazon.com/vpc/latest/userguide/vpc-sharing.html#vpc-share-limitations"&gt;limitations&lt;/a&gt;, make sure you’re accounting for them in your design. &lt;/p&gt;

&lt;h3&gt;
  
  
  🎯AWS PrivateLink
&lt;/h3&gt;

&lt;p&gt;Are you itching to know the options if you need asymmetric flow connectivity? No. Let me tell you anyway. 😄&lt;/p&gt;

&lt;p&gt;AWS PrivateLink provides private IP connectivity between VPCs so that clients can connect with services hosted in other VPCs. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yPN29UBT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.craft.do/user/full/9d54cc03-adfe-f72f-3389-565eb7356d1d/doc/E750C457-EBD6-4BC9-B64B-82503E319F6A/70E8E1B1-8E55-482C-A5A5-435FA3556D0E_2/nVchuZuBuchYYExghfQZ08YGb1H0o5dDpPpTqgcjA80z/Image.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yPN29UBT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.craft.do/user/full/9d54cc03-adfe-f72f-3389-565eb7356d1d/doc/E750C457-EBD6-4BC9-B64B-82503E319F6A/70E8E1B1-8E55-482C-A5A5-435FA3556D0E_2/nVchuZuBuchYYExghfQZ08YGb1H0o5dDpPpTqgcjA80z/Image.png" alt="image" width="880" height="457"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The key benefit over VPC sharing or peering is that PrivateLink connects services even when they run in different VPCs with overlapping CIDRs. It is also simpler to set up as it doesn’t require changes to route tables, subnets, or TGWs.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The AWS Prescriptive Guidance has a guide for using &lt;a href="https://docs.aws.amazon.com/prescriptive-guidance/latest/patterns/access-container-applications-privately-on-amazon-eks-using-aws-privatelink-and-a-network-load-balancer.html"&gt;PrivateLink and NLB with EKS&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Symmetric flow with PrivateLink
&lt;/h3&gt;

&lt;p&gt;If you choose to interconnect services using PrivateLink, you can still provide support for symmetric flow You’d have to add another PrivateLink to support connections originating from the opposite end.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Chc3HHEz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.craft.do/user/full/9d54cc03-adfe-f72f-3389-565eb7356d1d/doc/E750C457-EBD6-4BC9-B64B-82503E319F6A/80E31C46-F8E3-4A00-996F-DEA674B4B1F0_2/Ouq2THBcarrvUdy9l4T3IkYLaFs2hQVy9MeQa7CyNUcz/Image.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Chc3HHEz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.craft.do/user/full/9d54cc03-adfe-f72f-3389-565eb7356d1d/doc/E750C457-EBD6-4BC9-B64B-82503E319F6A/80E31C46-F8E3-4A00-996F-DEA674B4B1F0_2/Ouq2THBcarrvUdy9l4T3IkYLaFs2hQVy9MeQa7CyNUcz/Image.jpeg" alt="image" width="880" height="484"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Cost comparison
&lt;/h2&gt;

&lt;p&gt;I researched &lt;a href="https://aws.amazon.com/privatelink/pricing/"&gt;PrivateLink pricing&lt;/a&gt; and failed to come up with a fair comparison with &lt;a href="https://aws.amazon.com/transit-gateway/pricing/"&gt;Transit Gateway&lt;/a&gt;. Unfortunately, there are too many vectors to provide a generalized price comparison. I recommend involving an AWS Solutions Architect for a detailed analysis.  &lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;AWS provides many methods to connect services running in different VPCs. This post reviews the options available for EKS customers. &lt;/p&gt;

&lt;p&gt;You can simplify network topologies by interconnecting shared Amazon VPCs using connectivity features, such as AWS PrivateLink, transit gateways, and VPC peering.&lt;/p&gt;

&lt;p&gt;Here’s a rudimentary decision tree to help you get started. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--h3LTkoSI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.craft.do/user/full/9d54cc03-adfe-f72f-3389-565eb7356d1d/doc/E750C457-EBD6-4BC9-B64B-82503E319F6A/72D10F42-0962-48E4-943A-9FE276BE2F8E_2/PqYS0hmHvG8fvXAKk6qx2F1t8kRnisyheEEtzekxtNMz/Image.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--h3LTkoSI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.craft.do/user/full/9d54cc03-adfe-f72f-3389-565eb7356d1d/doc/E750C457-EBD6-4BC9-B64B-82503E319F6A/72D10F42-0962-48E4-943A-9FE276BE2F8E_2/PqYS0hmHvG8fvXAKk6qx2F1t8kRnisyheEEtzekxtNMz/Image.png" alt="image" width="466" height="681"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Did I get anything wrong? Please tweet me your feedback at &lt;a href="https://twitter.com/realz"&gt;@realz&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Further Reading
&lt;/h2&gt;

&lt;p&gt;AWS Whitepaper: &lt;a href="https://d1.awsstatic.com/whitepapers/aws-privatelink.pdf"&gt;Securely Access Services Over AWS PrivateLink&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;AWS Whitepaper: &lt;a href="https://d1.awsstatic.com/whitepapers/building-a-scalable-and-secure-multi-vpc-aws-network-infrastructure.pdf"&gt;Building a Scalable and Secure Multi-VPC AWS Network Infrastructure&lt;/a&gt;&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>aws</category>
      <category>cloud</category>
    </item>
    <item>
      <title>What are Rollups 🍣</title>
      <dc:creator>Re Alvarez-Parmar</dc:creator>
      <pubDate>Tue, 22 Mar 2022 20:32:49 +0000</pubDate>
      <link>https://dev.to/realz/what-are-rollups-g0o</link>
      <guid>https://dev.to/realz/what-are-rollups-g0o</guid>
      <description>&lt;p&gt;Increasing the transactional throughput of public blockchains is a key focus for blockchain researchers today. &lt;a href="https://eips.ethereum.org/EIPS/eip-4844"&gt;EIP-4844&lt;/a&gt; just came out, and it's old news that rollups will play a huge role in the future of scaling Ethereum. Ethereum's co-founder Vitalik Buterin described the concept of rollups back in 2014. Last year, Vitalik &lt;a href="https://vitalik.ca/general/2021/01/05/rollup.html"&gt;claimed rollups to be the “only choice" for making gas fees more affordable&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Rollups offer faster and cheaper transactions for dApp developers and their customers. This post summarizes my research on rollups, and a few things dApp developers should know when picking the right blockchain protocol.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2OadE9YP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.craft.do/user/full/9d54cc03-adfe-f72f-3389-565eb7356d1d/doc/1C445B41-B14F-4E8F-9208-E6D7E9565D52/86D1780C-B4FD-4AF8-BF0B-256F24627357_2/AxrzzGRiNYaxyhbjmnipvXDP38mulKJn0G1WKVtYy6Iz/Image.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2OadE9YP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.craft.do/user/full/9d54cc03-adfe-f72f-3389-565eb7356d1d/doc/1C445B41-B14F-4E8F-9208-E6D7E9565D52/86D1780C-B4FD-4AF8-BF0B-256F24627357_2/AxrzzGRiNYaxyhbjmnipvXDP38mulKJn0G1WKVtYy6Iz/Image.jpeg" alt="Image.jpeg" width="880" height="519"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why do we need rollups? 🛼
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Rollups are in the short and medium-term, and possibly in the long term, the only trustless scaling solution for Ethereum.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Thanks Vitalik for that intro. If you’re familiar with Ethereum, you also know about the current gas prices crises. Basically, if you transfer coins on Ethereum, be prepared to fork over up to $10 in fees to send $1. The last sentence may not be an exaggeration. 😔&lt;/p&gt;

&lt;p&gt;Rollups are a layer 2 scaling solution to drastically reduce the gas price on the Ethereum mainnet. Rollups are supposed to provide a way to reduce the costs and latency of decentralized applications (dApps) for users and developers.&lt;/p&gt;

&lt;p&gt;In layer 2 scaling solutions, web3 apps send transactions to nodes that are part of the layer 2 network, then the network batches transactions into groups before &lt;em&gt;anchoring (publishing)&lt;/em&gt; them to layer 1, after which they are secured by layer 1 since they are publicly verifiable and cannot be altered. Thus rollups offer faster execution by executing transactions off-chain and publishing the proof of transactions on-chain.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Rollups move computation (and state storage) off-chain, but keep some data per transaction on-chain.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;A rolledup transaction could include tens of thousands of transactions, which means tens of thousands of transactions can be recorded on the mainchain for the price of one. Using compression algorithms, the more layer 2 transactions you can bundle in a single layer 1 transaction, the cheaper it is to store proof of transactions.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://jsidhu.medium.com/the-ultimate-guide-to-rollups-f8c075571770"&gt;Jag Sidhu &lt;/a&gt;writes “some Ethereum engineers got these individual account updates down to a few bytes (8–12 bytes depending on the implementation) which means that a block with 1 megabyte of bandwidth would be able to roughly process 83k — 125k account adjustments per block and around 5500 to 8300 TPS theoretically assuming 15 second block times.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--y00RVFRT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.craft.do/user/full/9d54cc03-adfe-f72f-3389-565eb7356d1d/doc/1C445B41-B14F-4E8F-9208-E6D7E9565D52/3B62E811-91E8-408B-9B3C-574AA058D50D_2/90FGxI1BElqAd7GnK8ViyaIAo4JYzzIgsNZkhbmqXKwz/Image.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--y00RVFRT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.craft.do/user/full/9d54cc03-adfe-f72f-3389-565eb7356d1d/doc/1C445B41-B14F-4E8F-9208-E6D7E9565D52/3B62E811-91E8-408B-9B3C-574AA058D50D_2/90FGxI1BElqAd7GnK8ViyaIAo4JYzzIgsNZkhbmqXKwz/Image.jpeg" alt="Image.jpeg" width="880" height="546"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://wwz.unibas.ch/fileadmin/user_upload/wwz/00_Professuren/Schaer_DLTFintech/Lehre/Tobias_Schaffner_Masterthesis.pdf"&gt;Image source&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Types of rollups
&lt;/h2&gt;

&lt;p&gt;The paper subtly categorizes rollups into two prominent categories: Arbitrum and Optimism with fees that are ~3-8x lower gas fees than L1 and ZK-rollups, with ~40-100x lower gas fees than Ethereum mainnet.&lt;/p&gt;

&lt;p&gt;So, what’s the difference between Arbitrum and Optimism that provide single-digit gains than ZK-rollups with triple-digit gains? That’s because there are two types of layer 2 scaling solutions: Optimistic and ZK.&lt;/p&gt;

&lt;h3&gt;
  
  
  Optimistic rollups
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://offchainlabs.com"&gt;Arbitrium&lt;/a&gt; and &lt;a href="https://www.optimism.io"&gt;Optimism&lt;/a&gt; are layer 2 protocols that use “optimistic rollup” (OR) to scale Ethereum. An optimistic rollup network assumes that transactions are valid by default and only performs calculations, via a fraud proof, in the event of a challenge.&lt;/p&gt;

&lt;p&gt;In other words, when an application transacts on an optimistic rollup network like Arbitrum, the actual transfer of funds (from &lt;em&gt;accountA&lt;/em&gt; to &lt;em&gt;accountB&lt;/em&gt;) happens on the Arbitrum. The transaction is then published on Ethereum mainnet.&lt;/p&gt;

&lt;p&gt;Remember that an optimistic rollup network assumes all transactions are valid, at least initially. So what happens if a transaction in invalid?&lt;/p&gt;

&lt;p&gt;This is indeed a problem with optimistic rollups. Because, every transaction is assumed valid, optimistic rollups have a &lt;em&gt;withdrawal time (7-14 days)&lt;/em&gt; constraints while the network waits for &lt;em&gt;someone else&lt;/em&gt; to challenge the state of the network.&lt;/p&gt;

&lt;p&gt;Optimistic Rollups rely on fraud proofs to avoid re-computations. The state is proposed to Ethereum by a “bonded” actor. Anyone who wants to challenge the actor may claim a bounty by proving that the state update is inaccurate. To accomplish this, the challenger must provide the data required by the smart contract to prove the inaccuracy. &lt;a href="https://threadreaderapp.com/thread/1395812308451004419.html"&gt;This thread&lt;/a&gt; goes over the key difference between Optimism and Arbitrum fraud proof mechanism.&lt;/p&gt;

&lt;p&gt;ZK-rollups don’t have the withdrawal time constraint because they include a validity proof.&lt;/p&gt;

&lt;h3&gt;
  
  
  ZK Rollups
&lt;/h3&gt;

&lt;p&gt;For Ethereum — and EVM compatible chains — to become world’s next distributed computing platform, gas prices have to be massively reduced, until it is cheaper to do things at internet scale. ZK rollups (ZKR) promise could be the key to achieving that level of scalability.&lt;/p&gt;

&lt;p&gt;ZK rollups like &lt;a href="https://zksync.io"&gt;zkSync&lt;/a&gt; are popular because they don’t have the &lt;em&gt;withdrawal time&lt;/em&gt; problem that optimistic rollups do. Withdrawal times in zkSync, a ZK rollup live on Ethereum mainnet, are 10 minutes to 7 hours during low usage. Moreover, ZK rollups gets cheaper and faster as the usage increases, so in the future things will become faster.&lt;/p&gt;

&lt;h2&gt;
  
  
  But, what does ZK stand for?
&lt;/h2&gt;

&lt;p&gt;ZK rollups are based on the concept of provers and verifiers. ZK stands for Zero Knowledge.&lt;/p&gt;

&lt;p&gt;ZKR "roll-up" off-chain transactions and generate a cryptographic proof known as a zk-SNARK. The acronym &lt;a href="https://en.wikipedia.org/wiki/Non-interactive_zero-knowledge_proof"&gt;zk-SNARK&lt;/a&gt; stands for “Zero-Knowledge Succinct Non-Interactive Argument of Knowledge". The zk-SNARK is the proof of validity of the transactions in the form of a hash and is eventually placed on the main chain.&lt;/p&gt;

&lt;p&gt;A special ZK Rollup smart contract, which resides on Layer 1, maintains the status of the transfers made on rollup chain. The status can only be updated with a validity card; the zk-SNARK. The zk-SNARK is a hash that represents the blockchain's validity status.&lt;/p&gt;

&lt;p&gt;“Zero-knowledge” proofs allow one party (the prover) to prove to another (the verifier) that a statement is true without revealing any information beyond the validity of the statement itself. For example, given the hash of a random number, the prover could convince the verifier that there indeed exists a number with this hash value, while disclosing what that random number is.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In a zero-knowledge “Proof of Knowledge” the prover can convince the verifier not only that the number exists, but that they in fact know such a number – again, without revealing any information about the number.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;zk-SNARK’s succinct proofs are only a few hundred bytes and can be verified within a few milliseconds. The ZK proof mathematically proves that no fraud has occurred.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://zksync.io"&gt;zkSync&lt;/a&gt; is a ZKR live on Ethereum mainnet. &lt;a href="https://www.immutable.com"&gt;Immutable X&lt;/a&gt; and &lt;a href="https://loopring.io/#/"&gt;Loopring&lt;/a&gt; also use ZKR. &lt;a href="https://z.cash"&gt;Zcash&lt;/a&gt; is the first widespread application of zk-SNARKs. Polygon is focused on Zero-Knowledge (ZK) cryptography as the end game for blockchain scaling. There's a lot of innovation happening in this space. &lt;a href="https://l2beat.com"&gt;L2beat.com&lt;/a&gt; provides details about Ethereum layer 2 scaling solutions.&lt;/p&gt;

&lt;h3&gt;
  
  
  ZKR core components
&lt;/h3&gt;

&lt;p&gt;ZKRs execute transactions on sidechain and roll them on the mainchain. ZKR use two transactors and relayers to achieve this.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Transactor&lt;/strong&gt; create and broadcast transaction data (indexed address, value, network fee, and nonce) to the network. Transactor corresponds to an external account on Ethereum. Smart contracts then record addresses to one Merkle Tree and the transaction value to another.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Relayers&lt;/strong&gt; collect a large number of transactions creating rollups. Relayers generate the ZK proof that creates the blockchain &lt;em&gt;state&lt;/em&gt; before and after each transaction. The resulting changes reach the mainchain in a verifiable hash. Although anyone can become a relayer, you must first stake their cryptocurrency in a smart contract to ensure honesty.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;This “&lt;strong&gt;state&lt;/strong&gt;” is essentially a database which represents new balances and adjustments to accounts as users transact with their accounts inside of the rollup&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  How do rollups reduce gas?
&lt;/h3&gt;

&lt;p&gt;Rollups don’t actually reduce the gas on Ethereum. Recall that a rollup is a layer 2 sidechain; when using a rollup, you won’t be sending transactions on Ethereum mainnet; instead transactions will be submitted to the L2.&lt;/p&gt;

&lt;p&gt;Users of a dApp running the ZK-Rollup scheme will pay less in transaction fees.&lt;/p&gt;

&lt;h2&gt;
  
  
  Are Optimistic Rollups a temporary solution?
&lt;/h2&gt;

&lt;p&gt;This seems to be a common question in the community. If ZKR are faster, then why even bother with OR?&lt;/p&gt;

&lt;p&gt;Optimistic rollups have a first-mover advantage. First of all, the main reason why OR were more popular in the past was because until recently ZKRs didn't support Solidity smart contracts. ZKRs have to generate validation proofs, and the earliest iterations were not EVM and Solidity compatible. That changed in 2021. Now you can take your Solidity smart contract and deploy it on a ZKR with a few (relatively minor) changes.&lt;/p&gt;

&lt;p&gt;On Feb 2022, zkSync 2.0 became available on Ethereum’s testnet. &lt;a href="https://docs.zksync.io/zkevm/"&gt;zkEVM&lt;/a&gt; is a virtual machine that executes smart contracts in a way that is compatible with zero-knowledge-proof computation.&lt;/p&gt;

&lt;p&gt;Only time will tell who wins.&lt;/p&gt;

&lt;h3&gt;
  
  
  How will the merge affect this?
&lt;/h3&gt;

&lt;p&gt;Simply put, it will not. I’ll provide a detailed answer in another post.&lt;/p&gt;

&lt;h2&gt;
  
  
  Topics we skipped
&lt;/h2&gt;

&lt;p&gt;In optimistic rollups, when transactions are ready to be rolled up, a &lt;strong&gt;sequencer&lt;/strong&gt; is a specially designated full node that can control the ordering of transactions. Sequencers bundle transactions and submit both the transaction data and the new L2 state root to L1. Kyle Charbonnet has explained Optimism's optimistic rollup implementation in detail &lt;a href="https://medium.com/privacy-scaling-explorations/an-introduction-to-optimisms-optimistic-rollup-8450f22629e8"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://starkware.co/stark/"&gt;&lt;strong&gt;ZK-STARK&lt;/strong&gt; (Zero-Knowledge Scalable Transparent ARguments of Knowledge)&lt;/a&gt;. The proof system used in ZK-SNARK requires a trusted party, or parties, to initially set up the ZK proof system. A dishonest trusted party could compromise the privacy of the system. ZK-STARKS improve on this technology by removing the need for a trusted setup.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Blockchain is a fast-moving space. Millions of dollars continue to be funneled into building scalable future blockchain networks. It’s hard to tell if ZKRs will be the silver bullet to address Ethereum’s data availability and scaling problems. In the short term, it does look like ZKRs are a step in the right direction.&lt;/p&gt;




&lt;h3&gt;
  
  
  References
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://www.reddit.com/r/CryptoCurrency/comments/nctot7/defi_explained_zk_rollups/"&gt;DeFi Explained: ZK Rollups&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.reddit.com/r/CryptoCurrency/comments/rvktc1/what_are_zkrollups_and_why_theyre_the_best/"&gt;What are ZK-Rollups and why they're the best investment you can make in 2022.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://jsidhu.medium.com/the-ultimate-guide-to-rollups-f8c075571770"&gt;The Ultimate Guide to Rollups&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://curve.substack.com/p/february-20-2021-optimistic-vs-zk?s=r"&gt;February 20, 2021: Optimistic vs ZK-Rollups, ELI5 🧒🧑‍🏫&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://finematics.com/rollups-explained/"&gt;Rollups – The Ultimate Ethereum Scaling Solution – Finematics&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://vitalik.ca/general/2021/01/05/rollup.html"&gt;An Incomplete Guide to Rollups&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://research.paradigm.xyz/optimism"&gt;How does Optimism’s Rollup really work?&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://z.cash/technology/zksnarks/"&gt;What are zk-SNARKs? | Zcash&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://wwz.unibas.ch/fileadmin/user_upload/wwz/00_Professuren/Schaer_DLTFintech/Lehre/Tobias_Schaffner_Masterthesis.pdf"&gt;Scaling Public Blockchains&lt;/a&gt;
&lt;a href="https://medium.com/privacy-scaling-explorations/an-introduction-to-optimisms-optimistic-rollup-8450f22629e8"&gt;An Introduction to Optimism’s Optimistic Rollup&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ethereum</category>
      <category>blockchain</category>
      <category>zkrollups</category>
      <category>web3</category>
    </item>
  </channel>
</rss>
