<?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 Andreas Seficha on Medium]]></title>
        <description><![CDATA[Stories by Andreas Seficha on Medium]]></description>
        <link>https://medium.com/@aseficha?source=rss-477b1b8c5f82------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*f0Hf205vdTO91yh9thstnQ.jpeg</url>
            <title>Stories by Andreas Seficha on Medium</title>
            <link>https://medium.com/@aseficha?source=rss-477b1b8c5f82------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 05:47:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@aseficha/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[Cost optimization on Databricks]]></title>
            <link>https://aseficha.medium.com/cost-optimization-on-databricks-7e6834218f47?source=rss-477b1b8c5f82------2</link>
            <guid isPermaLink="false">https://medium.com/p/7e6834218f47</guid>
            <category><![CDATA[spark]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[delta-lake]]></category>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[cost]]></category>
            <dc:creator><![CDATA[Andreas Seficha]]></dc:creator>
            <pubDate>Fri, 24 Feb 2023 13:00:34 GMT</pubDate>
            <atom:updated>2023-02-24T13:00:34.015Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cGa2pulhLsHuElXc" /><figcaption>Photo by <a href="https://unsplash.com/@micheile?utm_source=medium&amp;utm_medium=referral">micheile dot com</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Databricks is a very powerful platform but the cost can sometimes seem prohibitive for small and medium-sized companies. I recently had to deal with a client that blew through their yearly databricks budget in less than a quarter.</p><p>Let’s start by analyzing databricks’ pricing model. For the sake of this exercise, I will showcase the thought process on a AWS backed workspace, but the same can be applied to other cloud providers like GCP and Azure.</p><h3>Workspace type selection</h3><p>The first choice that has to be made is the selection of a workspace plan. There are three to choose, Standard, Premium and Enterprise. We will focus on the first two as the last one differentiates itself mostly around compliance and security around mission-critical data.</p><p>The standard type lacks some features like Databricks SQL, Unity catalog and cluster policies, but for scenarios where we want an optimized spark job to run, it could be a good choice, especially given its’ better price per DBU (databricks unit) for Job clusters</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hGLh7vx76Yz6r-SaReVLGQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1OqDP6K9MX1eNIj5rOugiA.png" /></figure><h3>Light, Normal or Photon</h3><p>Jobs light is the cheapest option in databricks, but it comes with caveats as they are not compatible with Delta Lake, so I would mostly stay away from them. Photon is very new to the game and is a completely new processing engine compatible with Spark APIs. Based on the usage pattern that I have seen, there are a lot of use cases where Photon leads to more performant workloads. On the flipside, Photon is compatible with a limited set of EC2 instance types. This has to be dealt with at a use case level and via experimentation with different setups</p><h3>Pricing Model</h3><p>A critical point that needs to be mentioned is that databricks has two pricing models, pay as you go and committed use. By committing to spend a certain amount of money, you can get big discounts on your workloads and gain access to other perks like monthly checks with solution architects or support</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W_Fvb2-mlmRgYyAbfsXRYw.png" /></figure><h3>Automation vs Interactive workloads</h3><p>The single most common error that most companies make when using databricks is scheduling automated workloads on ‘All-Purpose’ compute clusters. These clusters are easy to create and attach notebooks and can be used for interactive data science, machine learning workloads, data engineering, BI and data analytics. The problem is that these clusters are expensive (3.5x the cost of a job cluster) and will also result in decreased performance in case they are shared e.g. A data scientist is running an experiment while a daily batch tries to use the same cluster to run.</p><h3>Idle Timeout on Clusters</h3><p>A good practice is to set reasonable auto-termination policies on all-purpose clusters, so they shut down when not in use.</p><h3>SQL workloads</h3><p>If all you are doing is writing SQL to query your delta lake data, consider moving away from all purpose clusters and using sql warehouses or serverless sql (sql not available in Standard workspaces). SQL uses photon by default, and with a serverless setup you can save even more with massively parallel processing and predictive I/O.</p><p>Serverless pricing includes the instance cost as well as the databricks premium</p><p>Pro note: There is an ongoing promo from databricks for workloads utilizing SQL Pro and SQL Serverless up to January 31 2024.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cqfJ1MOe5_pTQUDHmDHA7w.png" /></figure><h3>Instance Types</h3><p>Having regular audits of the instance types used is a good practice. In AWS I would highly recommend current-generation Graviton instances as they provide the best price-to-performance ration. As an example:</p><pre>m5.large costs $0.0860 hourly in us-east-1 (on-demand)<br>m6g.large costs $0.0770 hourly in us-east-1 (on-demand)</pre><p>Other optimizations that mainly impact the AWS bill are:</p><h3>Spot Instances</h3><p>Make it a habit of creating idempotent workflows and using spot instances. Although there is no DBU difference in databricks cost, there is a huge benefit on the AWS bill.</p><h3>Time travel side effects</h3><p>Another topic that is often forgotten about is that while the time travel is a great feature of delta lake it introduces hidden costs. Let me explain. Every time you mutate data or partitions in a delta lake, a new version will be created. The old version is not deleted, though from s3. That is what allows us to go to a previous state of our table. Databricks mentions that by default, versions are kept for 14 days and delta logs are kept for 30 days. What is not clear is that after this time, the data IS NOT deleted; it is simply marked as ‘ready for deletion’. You need to manually run the VACUUM command on the table to clean up the stale files in order to avoid having old versions taking space on your object store indefinitely</p><h3>Track your costs</h3><p>The basic dashboards provided by Databrics on the main account are not nearly enougn to deep dive and do proper cost analysis as they provide a simple daily breakdown by DBU or USD.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_2MboHyHz_eM_liFpSPs2Q.png" /></figure><p>Take advantage of the usage logs delivery. That is feature that allows for automated billage usage logs delivery to an object store location. You can then build custom dashboards on top of this data, breakdown by type, team, tags and usage or create alerts that can notify you of irregular spending or a sudden increase.</p><h3>Summary</h3><p>There are a lot of parameters that, as you see, can drive the databricks cost either up or down.</p><ul><li>Decide early on the workspace type.</li><li>Limit all purpose cluster usage as much as possible.</li><li>Optimize job clusters with Photon and Graviton instances</li><li>Use spot especially when running small and idempotent loads</li><li>Check for hidden costs brought by time travel and automate the vacuum process</li><li>Enable usage log delivery and prioritize creating comprehensive dashboards and alerts.</li></ul><p>Thank you for your valuable time! If you have enjoyed this article, clap &amp; share it so more people can see it! To see similar posts, follow me on <a href="https://medium.com/@aseficha">Medium</a> &amp; <a href="https://www.linkedin.com/in/andreas-seficha/">LinkedIn</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7e6834218f47" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Solve Communication Problems in Cross-Team Dependent Companies Using AWS EventBridge]]></title>
            <link>https://aws.plainenglish.io/central-event-bus-a-tale-of-connecting-your-fragmented-teams-f0c87247da15?source=rss-477b1b8c5f82------2</link>
            <guid isPermaLink="false">https://medium.com/p/f0c87247da15</guid>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Andreas Seficha]]></dc:creator>
            <pubDate>Thu, 21 Oct 2021 10:45:46 GMT</pubDate>
            <atom:updated>2021-10-22T12:43:34.767Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Problem</h3><p>It is not uncommon for companies to maintain separate teams that handle specific features or data of an application. Everyone can work agile and fast while handling their domain, but communication problems start to arise the moment cross-team dependencies are introduced.</p><p>Questions like: ‘How do I know a specific action happened, so I react to that?’, ‘How can I propagate a business event (e.g user signup)?’, ‘How can I let other teams know that a processing pipeline has finished?’ are just a few cases that indicate that syncing processes and actions between teams can become a burden and cause delays in development</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*8Kkl3RYg5w9TcjPsqKUR7Q.png" /><figcaption>Team to Team Communication</figcaption></figure><p>As you can see from the diagram above the complexity of sharing updates/events with other teams can quickly grow to unmanageable levels, making it hard to identify :</p><ul><li>Event types and schemas are very hard to standardise, teams might end up producing/consuming multiple variations of the same event</li><li>Medium for relaying events. Is a queue being used or a stream or something entirely different? The teams have to decide beforehand the ‘contract’ for sharing events and align their internal technologies for producing/consuming</li></ul><h3>Brainstorming the Components</h3><p>Before we come up with a solution, we first need to understand the distinct components that need to be addressed to streamline and centralise the event propagation efforts.</p><h4>Schema</h4><p>The contract of data or definition of the event must be standardised, documented, and available to all teams. Every team that wants to consume a specific event should be able to quickly hook to a bus and receive well-structured events. Every team that wants to produce an event should be able to do so with minimal effort and make it available to everyone interested.</p><h4>Bus</h4><p>The medium of event propagation should be centrally accessible, abstract enough to allow teams to consume data in a way that fits their internal technologies and flexible enough to allow easily ‘subscribing to events’</p><h3>Solution in AWS</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*Qu6cuKepvcxq8t2kScebvQ.png" /></figure><h3>EventBridge</h3><p>Amazon EventBridge is a serverless event bus that makes it easier to build event-driven applications at scale using events generated from your applications, integrated Software-as-a-Service (SaaS) applications, and AWS services.</p><p>EventBridge delivers a stream of real-time data from event sources such as Zendesk or Shopify to targets like AWS Lambda and other SaaS applications. You can set up routing rules to determine where to send your data to build application architectures that react in real-time to your data sources with event publisher and consumer completely decoupled.</p><p>The main takeaways here are that EventBridge is <strong>serverless</strong>, meaning no infrastructure management is required; it is based on<strong> routing rules</strong> that make the propagation of events a trivial task and that it connects to a <strong>multitude of sources and targets</strong>.</p><p>EventBridge is the evolution of Cloudwatch events and integrates very easily with most AWS services as well as external providers.</p><h4>Rules</h4><p>Rules define the pattern-matching and dictate the sinks or targets of the events.</p><h4>Pattern</h4><p>A pattern describes in detail the different ways to do pattern matching:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IrG81NyQTu_a2lbqtp2htg.png" /></figure><p>In the link below you can find more information on how to do event matching:</p><p><a href="https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-event-patterns.html">Amazon EventBridge event patterns</a></p><h4>Target</h4><p>A maximum of 5 targets can be set for a single rule.</p><p>The AWS targets are defined here:</p><p><a href="https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-targets.html">Amazon EventBridge targets</a></p><h4>Third-Party Providers</h4><p>Partner integrations allow external providers to send events directly to an EventBridge. All the partner integrations are located here:</p><p><a href="https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-saas.html">Receiving events from a SaaS partner with Amazon EventBridge</a></p><h3>Cross-Account Central Bus</h3><p>A lot of organisations maintain separate team accounts. A central bus in such a case is still feasible but requires a bit more thought.</p><h4>The Central Account</h4><p>An account must be chosen to act as the central integration hub. It will contain the event bus where all other accounts put events at.</p><p>To enable cross-account PutEvents, a resource policy needs to be attached to the shared central bus, that will allow team account to put events into the bus:</p><pre>{<br> “Version”: “2012–10–17”,<br> “Statement”: [{<br> “Sid”: “AccountAccess”,<br> “Effect”: “Allow”,<br> “Principal”: {<br> “AWS”: [“arn:aws:iam::X:root”, “arn:aws:iam::X:root”, “arn:aws:iam::X:root”, “arn:aws:iam::X:root”, “arn:aws:iam::X:root”, “arn:aws:iam::X:root”, “arn:aws:iam::X:root”]<br> },<br> “Action”: “events:PutEvents”,<br> “Resource”: “arn:aws:events:eu-west-1:X:event-bus/central_event_bus_prod”<br> }]<br>}</pre><h4>Domain/Team Account</h4><p>To enable flexibility in rules matching and targets, each team maintains its local EventBridge. This bridge becomes a target of the central one.</p><p>To enable that, the following resource policy must be attached to the bus:</p><pre>{<br> “Version”: “2012–10–17”,<br> “Statement”: [{<br> “Sid”: “AllowPutEventsFromShared”,<br> “Effect”: “Allow”,<br> “Principal”: {<br> “AWS”: “arn:aws:iam::{SOURCE_ACCOUNT}:root”<br> },<br> “Action”: “events:PutEvents”,<br> “Resource”: “arn:aws:events:eu-west-1:{SHARED_ACCOUNT}:event-bus/datastar_staging”<br> }]<br>}</pre><p>Where SOURCE_ACCOUNT is the team’s account Id and SHARED_ACCOUNT the account Id of the account that houses the central bus.</p><p>By doing that the central bus can now use the domain’s local bus as a target of a rule.</p><h4>Event Propagation</h4><p>At this point, we need to decide how the routing is going to look like.</p><p>The easiest approach is to broadcast all the events to all the teams and allow the teams to create domain-specific rules and targets that fit their need.</p><p>Another approach would be to set specific rules on the central bus that will route only specific types of messages based on some defined criteria.</p><h3>Schema Discovery and Code Bindings</h3><p>The last piece of the puzzle is the schema definition and discovery. Amazon Event bridge allows automatic schema discovery on the sent events and also gives the ability to create custom registries and upload/download custom schemas as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QKIoBvbQMUUzQYK2Qgx7-g.png" /><figcaption>example schema for an aws ec2 event</figcaption></figure><p>The schema definitions use the OpenApi 3.0 type, a wildly used standard.</p><p>These schemas can be reflected into code by downloading the code binding for a specific language (Java, Python, Typescript).</p><p>A complete event may look like this:</p><pre>{<br>  &quot;version&quot;: &quot;0&quot;,<br>  &quot;id&quot;: &quot;6a7e8feb-b491-4cf7-a9f1-bf3703467718&quot;,<br>  &quot;detail-type&quot;: &quot;EC2 Instance State-change Notification&quot;,<br>  &quot;source&quot;: &quot;aws.ec2&quot;,<br>  &quot;account&quot;: &quot;111122223333&quot;,<br>  &quot;time&quot;: &quot;2017-12-22T18:43:48Z&quot;,<br>  &quot;region&quot;: &quot;us-west-1&quot;,<br>  &quot;resources&quot;: [&quot;arn:aws:ec2:us-west-1:123456789012:instance/i-1234567890abcdef0&quot;],<br>  &quot;detail&quot;: {<br>    &quot;instance-id&quot;: &quot;i-1234567890abcdef0&quot;,<br>    &quot;state&quot;: &quot;terminated&quot;<br>  }<br>}</pre><p>The detail-type identifies the specific schema that is passed as part of the event and the detail is the actual schema fields/properties:</p><p>The structure of the downloaded binding looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*vW-dFgHrqOOWs_s_NGUOnQ.png" /></figure><p>The AWSEvent.py contains the wrapper object that is responsible for generating the whole event sent to EventBridge. It is the class responsible for generating the example mentioned above.</p><p>In our example, the EC2InstanceLaunchLifecycleAction.py contains the specific properties/fields for the schema we are interested in (detail key in the example event above) and the marshaller.py contains methods to marshall and un-marshall to/from the AWSEvent.py.</p><h3>Final Thoughts</h3><p>Centralising event propagation is usually a difficult topic but with proper tools like EventBridge and well-defined rules and targets we can see that the topic becomes trivial to resolve, while allowing great flexibility regarding the way the teams want to consume and handle the events.</p><p>I hope you have found the article insightful, take a moment to clap and follow my profile for more interesting content.</p><p><em>More content at </em><a href="http://plainenglish.io/"><em>plainenglish.io</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f0c87247da15" width="1" height="1" alt=""><hr><p><a href="https://aws.plainenglish.io/central-event-bus-a-tale-of-connecting-your-fragmented-teams-f0c87247da15">How to Solve Communication Problems in Cross-Team Dependent Companies Using AWS EventBridge</a> was originally published in <a href="https://aws.plainenglish.io/">AWS in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[End to end pipeline mocking with localstack and Airflow MWAA]]></title>
            <link>https://aws.plainenglish.io/end-to-end-pipeline-mocking-with-localstack-and-airflow-mwaa-ac4f019c3a0e?source=rss-477b1b8c5f82------2</link>
            <guid isPermaLink="false">https://medium.com/p/ac4f019c3a0e</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[testing]]></category>
            <dc:creator><![CDATA[Andreas Seficha]]></dc:creator>
            <pubDate>Fri, 13 Aug 2021 10:06:33 GMT</pubDate>
            <atom:updated>2021-08-13T14:25:21.712Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HVc4A3qdUrOCuiZoptTOlQ.png" /></figure><p>It is not a secret that with workflow orchestration tools like Airflow, testing and iterating a pipeline is notoriously hard, especially when cloud components come to play.</p><p>In this article, we will explore an easy way to set up a complete mock infrastructure setup using docker compose, localstack, and the mwaa (AWS-managed airflow solution) docker image.</p><h3>Localstack</h3><p>Localstack provides an easy mocking framework for developing AWS cloud applications.</p><p><a href="https://github.com/localstack/localstack">GitHub - localstack/localstack: 💻 A fully functional local AWS cloud stack. Develop and test your cloud &amp; Serverless apps offline</a></p><p>There is a multitude of supported services out of the box</p><ul><li>ACM, API Gateway, CloudFormation, CloudWatch, CloudWatch Logs, DynamoDB, DynamoDB Streams, EC2, Elasticsearch Service, EventBridge (CloudWatch Events), Firehose, IAM, Kinesis, KMS, Lambda, Redshift, Route53, S3, SecretsManager, SES, SNS, SQS, SSM, StepFunctions, STS.</li></ul><p>In the case of our flow, these services suffice to implement our use cases.</p><h3>MWAA runner</h3><p>Amazon provides a local image with their version of Airflow that makes emulating the production environment easier.</p><p><a href="https://github.com/aws/aws-mwaa-local-runner">GitHub - aws/aws-mwaa-local-runner: This repository provides a command line interface (CLI) utility that replicates an Amazon Managed Workflows for Apache Airflow (MWAA) environment locally.</a></p><p>We will focus on the /docker/docker-compose-local.yml and use that file as our entrypoint to create our testing infrastructure.</p><p>The docker-compose.yaml that follows contains an example setup to create a complete mock infrastructure</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/55008ce350fb9ab15546761af1f2f97b/href">https://medium.com/media/55008ce350fb9ab15546761af1f2f97b/href</a></iframe><p>Any additional libraries that need to be installed as part of the mwaa-runner can be added in a requirements.txt and be placed in the dags folder. That is different from the production aws service where the requirements is being added from a provided path in s3</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*X4_zQbFuE3YIN6QrXMPrqQ.png" /></figure><h3>Mesoshpere/aws-cli</h3><p>That is a docker image that contains the aws-cli and allows users to easily issue cli commands. Since with docker-compose we create a single network the localstack endpoint is accessible to the mesoshpere container and with aws-cli we are able to create mock resources.</p><p>We are almost there. So what have we achieved here?</p><p>The following resources are created</p><ul><li>A local airflow environment</li><li>2 s3 buckets (input/output)</li><li>An sqs queue</li><li>A dynamo db table with some data added from a file</li></ul><p>In this example we are mocking a pipeline with the following example structure:</p><pre>read and sqs message </pre><pre>||</pre><pre>check dynamdb for report location in s3 </pre><pre>||</pre><pre>read report from s3</pre><pre>||</pre><pre>persist transformed report in the output bucket</pre><h3>How does airflow work with localstack?</h3><p>Airflow integrates well with boto3 so it is almost plug and play with everything AWS.</p><p>We can either use boto directly and create a session using the localstack endpoint or get the sessions from an airflow hook directly. Airflow hooks have limited functionality and do not contain all available methods but we can extract the underlying boto connection as:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8f45bb34a0116fc883a05b00339a9467/href">https://medium.com/media/8f45bb34a0116fc883a05b00339a9467/href</a></iframe><p>Why go through this trouble though? Since we can set all the credentials, endpoints and assume-roles on connection level, it is cleaner to extract boto from the AwsBaseHook since we already have a nicely defined session that is handled/created for us.</p><p>For our case to work we need to add the localstack endpoint as host in the aws_default connection in airflow which is handled by this line in the docker-compose by:</p><pre>AIRFLOW_CONN_AWS_DEFAULT=aws://a:a@?host=http://localstack:4566&amp;region_name=us-east-1</pre><p>A note here if you edit the connection from airflow UI, is that the extras field is being used and not the host field to set the localstack endpoint</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2J43VvJBYLI1xC8FIy6wdg.png" /></figure><p>With those simple steps you have a local representation of MWAA and you can emulate most of the interactions with AWS services. That does not replace proper unit and integration testing but can help increase confidence before deploying a production load. It can also help save costs on needing a full-fledged developer setup in a real AWS account.</p><p><em>More content at </em><a href="http://plainenglish.io/"><em>plainenglish.io</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ac4f019c3a0e" width="1" height="1" alt=""><hr><p><a href="https://aws.plainenglish.io/end-to-end-pipeline-mocking-with-localstack-and-airflow-mwaa-ac4f019c3a0e">End to end pipeline mocking with localstack and Airflow MWAA</a> was originally published in <a href="https://aws.plainenglish.io/">AWS in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Personal Guide to Succeeding with AWS certifications]]></title>
            <link>https://aws.plainenglish.io/my-personal-guide-to-succeeding-with-aws-certifications-da4e894e57ac?source=rss-477b1b8c5f82------2</link>
            <guid isPermaLink="false">https://medium.com/p/da4e894e57ac</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[aws-certification]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[careers]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Andreas Seficha]]></dc:creator>
            <pubDate>Fri, 04 Jun 2021 11:44:31 GMT</pubDate>
            <atom:updated>2021-06-08T16:23:30.858Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6R8rrIKpqJ3hJgPr" /><figcaption>Photo by <a href="https://unsplash.com/@craftedbygc?utm_source=medium&amp;utm_medium=referral">Green Chameleon</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Some of the most in-demand and hot certifications nowadays are those that the known cloud providers offer. These are ways to validate your knowledge, NOT your experience, in the given space and serve as means to increase your opportunities getting hired.</p><p>In this article I am going to focus on AWS, where most of my experience lies and try to give you a detailed guide to properly prepare for any and all of the AWS certifications.</p><h3>Online video courses</h3><p>The first step is to understand the breadth of technologies that a given certification looks to cover. There are a lot of online video courses in most of the known websites like Udemy, Coursera, O’reilly, A Cloud guru that focus on the material for a given exam. My personal favourite is Udemy and I use it for other programming courses as well.</p><p>For me, that is the easiest way to:</p><ol><li>Get a brief understanding of technologies.</li><li>Familiarise oneself with all the topics covered in the exam (Example: security, networking, specific services).</li></ol><p>A small tip here: Udemy has sales very frequently so my advice is to wait for a discount and buy courses rather than blindly buying a course at full price.</p><h3>Whitepapers</h3><p>I have found out that the AWS whitepapers are a great source of information and contain a lot of details that can be critical for the exam questions.</p><p>The well-architected framework is a topic that is revisited in multiple certifications from different angles and is definitely a good starting point.</p><p><a href="https://aws.amazon.com/architecture/well-architected/?wa-lens-whitepapers.sort-by=item.additionalFields.sortDate&amp;wa-lens-whitepapers.sort-order=desc">AWS Well-Architected - Build secure, efficient cloud applications</a></p><p>The second pillar would be disaster recovery as introduced here:</p><p><a href="https://docs.aws.amazon.com/whitepapers/latest/disaster-recovery-workloads-on-aws/disaster-recovery-options-in-the-cloud.html">Disaster recovery options in the cloud</a></p><p>It is definitely worth taking a look at other papers as well and AWS provides an easy way to filter per topic/industry/technology.</p><p><a href="https://aws.amazon.com/whitepapers/?whitepapers-main.sort-by=item.additionalFields.sortDate&amp;whitepapers-main.sort-order=desc&amp;awsf.whitepapers-flag=*all&amp;awsf.whitepapers-content-type=*all&amp;awsf.whitepapers-content-category=*all&amp;awsf.whitepapers-global-methodology=*all&amp;awsf.whitepapers-business-category=*all&amp;awsf.whitepapers-tech-category=*all&amp;awsf.whitepapers-industries=*all">AWS Whitepapers &amp; Guides</a></p><p>Never underestimate those resources as I have noticed multiple questions deriving directly from those.</p><h3>Mock exams</h3><p>All the above is nice but the best way to become battle-tested is mock exams. These include ,among other, past questions and are the best way to get a feeling for the type of questions that is usually included in the exam.</p><p>My recommendation is to time each test and treat it like a real exam (no googling, hints, etc).</p><p>A few good sources are:</p><p>SkillCertPro: <a href="https://skillcertpro.com/">https://skillcertpro.com/</a></p><p>TutorialsDojo: <a href="https://tutorialsdojo.com/">https://tutorialsdojo.com/</a></p><p>Both of them have cheap exam packages that contain hundreds of questions. They provide hints and explanations for each answer, while also including links to relevant resources in AWS Docs.</p><h3>AWS Documentation Pages</h3><p>A lot of times, these resources are overlooked as ‘technical’ and too ‘developer-driven’ but to be honest, I have found them extremely helpful with all the nitty-gritty details that are usually expected in the exam.</p><p>I would visit all the resources that document, relevant for the examination, technologies and keep notes of details (especially numbers, security paths, encryption options, etc).</p><h3>Hands-on</h3><p>People, nothing beats hands-on practice. AWS has a free-tier that most the services fall in, its a great way to learn and it will cost close to nothing. Tick all the boxes, expand all menu items, search all the configuration options. I have found that is the best way to learn as you also combine visual stimuli with the written theory.</p><h3>Experience</h3><p>Well, duh! Although not a prerequisite, it always helps to have used cloud technologies in production. My first certification was the AWS Solutions Architect Associate and I can confirm that my prior experience in AWS was an immense help as I had already knowledge on most of the exam’s topics. Even the more experienced engineers though should follow the aforementioned path, to understand exactly the examination style and approach that is expected with said certifications.</p><h3>Set a deadline</h3><p>Once you have a good feeling about the level that you are (the mock exams will help with that), go and book the exam date in advance. The time needed is different for every individual and highly depends on prior experience as well. It is always better though to have a fixed window that you need to finish the preparation, rather than postponing it. Stop procrastinating, save some hours during the week for dedicated studying and start learning. Today, not tomorrow!</p><h3>Closing thoughts</h3><p>Don’t expect that by passing a certification you immediately become an AWS guru and everyone will want to hire you for your crazy awesome skills. The exam is tailored to make you learn good practices and validate your knowledge on a specific topic but it hardly substitutes production experience.</p><p>Get your hands dirty, build small (or big) proof of concepts, productionize your code and infrastructure. That is the only way to become an expert in the field.</p><p>A certification by itself is not a USP (unique selling point), combined though with real experience it can really make a change and make your CV shine</p><p><em>More content at </em><a href="http://plainenglish.io/"><em>plainenglish.io</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=da4e894e57ac" width="1" height="1" alt=""><hr><p><a href="https://aws.plainenglish.io/my-personal-guide-to-succeeding-with-aws-certifications-da4e894e57ac">My Personal Guide to Succeeding with AWS certifications</a> was originally published in <a href="https://aws.plainenglish.io/">AWS in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Guide to Demystifying Apache Spark’s Quirks]]></title>
            <link>https://aws.plainenglish.io/demystifying-apache-spark-quirks-2c91ba2d3978?source=rss-477b1b8c5f82------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c91ba2d3978</guid>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[apache-spark]]></category>
            <dc:creator><![CDATA[Andreas Seficha]]></dc:creator>
            <pubDate>Wed, 28 Oct 2020 17:43:10 GMT</pubDate>
            <atom:updated>2021-06-09T16:23:14.623Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WSm3IJqxo4J26ZvD" /></figure><p>After spending some time with Spark, I noticed some quirks while developing — some major, some minor. I hope this article helps shed some light on some difficulties and confusing aspects that a lot of Spark users have encountered over time.</p><h3>Compression</h3><p>Spark makes connecting to data sources a no-brain operation, providing a vast selection of connectors and easy to use syntax for different formats, like:</p><pre>val df = spark.read.jdbc(...)<br>val df = spark.read.json(...)<br>val df = spark.read.parquet(...)</pre><p>Some popular compression formats are the following:</p><ul><li><strong>SNAPPY</strong> – The default compression format for files in the Parquet data storage format.</li><li><strong>ZLIB</strong> – The default compression format for files in the ORC data storage format.</li><li><strong>LZO</strong></li><li><strong>GZIP</strong></li><li><strong>BZIP2</strong></li></ul><p>Spark does a good job of applying the proper codecs when wanting to compress an RDD/Dataframe and supports out of the box the following compression formats</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f_iLgdAbx7sh5ELm4_5AOQ.png" /></figure><p>And borrowing the following from Hadoop</p><pre>gzip    | .gz      | org.apache.hadoop.io.compress.GzipCodec</pre><p>So far so good. Let’s now try the following: reading a simple file from S3, which has JSON data and is gzipped, named 20200827 in the bucket test.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q74BiaemKudaYQGfEH_oGw.png" /></figure><pre>spark.read.json(&quot;s3a://test/20200827&quot;)<br>spark.printSchema()</pre><p>And that is what you are getting</p><pre>root<br> |-- _corrupt_record: string (nullable = true)</pre><p>So what happens? We just tried to read a JSON file that is gzipped and that should be trivial. In reality, Spark relies on <strong>file extensions</strong> to be able to identify the compression type via the getDefaultExtension() method (which for gzip is .gz). So, even though the file is compressed with gzip the lack of extension confuses spark.</p><p><strong>Solution:</strong> <strong>Name your files properly!</strong> There is no easy workaround! In this case, basically, we could extend the GzipCodec and override the getDefaultExtension().</p><p>With something like:</p><pre>package dre.spark.util.codecs<br><br>import org.apache.hadoop.io.compress.GzipCodec<br><br>class NoExtensionGzipCodec extends GzipCodec {<br><br>  override def getDefaultExtension(): String = &quot;&quot;<br><br>}</pre><p>Now, basically, whenever there is a file without extension, Spark would try to decode it as gzip. :(</p><p>If you only use gzip files, that should be enough.</p><p><strong>Outcome</strong>: Be careful with not having extensions, it’s a simple thing to have but creates a lot of problems when you don’t.</p><p><strong>Notes</strong>: One interesting thing to notice is that Glue (AWS serverless ETL offering) using the crawlers to create a data catalog and then the use of dynamic frames is able to handle the compression/decompression without any fuss.</p><h3>Partitioning in S3</h3><p>A good partition/bucket strategy in S3 goes a long way as it enables better performance and parallelisation while reading/writing data. The thing is that Spark is very specific regarding how the naming of the buckets must be to identify partition columns.</p><p>An example could be:</p><pre>-test-bucket<br>|<br>attribute1=values<br>  |<br>  attribute2=value1<br>    file1.json<br>    file2.json<br>    ...<br>  |<br>  attribute2=value2<br>    file1.json<br>    file2.json<br>...</pre><p>This is the ‘Hive style partitioning’. Nothing else will work, so be careful when writing data to s3 through some service believing you enable ‘partitioning’ for Spark.</p><p><strong>Notes: </strong>Again Glue. Arghhh. When you create a crawler in Glue it is able to identify partition columns without attribute information and create unnamed columns in the table as partition-0, partition-1, etc.</p><p>For example :</p><pre>-test-bucket<br>|<br>attribute1_value_1<br>  |<br>  attribute2_value1<br>    file1.json<br>    file2.json<br>    ...<br>  |<br>  attribute2_value2<br>    file1.json<br>    file2.json<br>...</pre><p>would create 2 columns partition_0 with values attribute1_value_1,attribute1_value_2 … and partition_1 with values attribute2_value_1, attribute2_value_2…</p><h3>S3 connectors</h3><p>I read somewhere that not all S3 connectors are created equal. There is a lot of truth in that statement.</p><p><strong>EMRFS</strong>: From the AWS docs: “implementation of the Hadoop file system used for reading and writing regular files from Amazon EMR directly to Amazon S3. EMRFS provides the convenience of storing persistent data in Amazon S3 for use with Hadoop while also providing features like Amazon S3 server-side encryption, read-after-write consistency, and list consistency”. When running Spark in EMR and store data in ‘HDFS’, that data is backed by s3 and can be accessed via using the URI scheme: s3://… Arguably the most performant from all the connectors</p><p><strong>S3n</strong>: A native filesystem for reading and writing regular files on S3. s. . The disadvantage is the 5GB limit on the size of the file in S3 and the average (bad) performance. To use (DON’T) use the URI scheme: s3n://…</p><p><strong>S3a</strong>: A newer version of the S3 Native, uses Amazon’s libraries to interact with S3. This allows S3a to support larger files (up to 5TB)better performance operations and more. PLEASE use the s3a over the s3n, the performance is hugely improved and the change is as simple as pointing the URI scheme to s3a://…</p><h3>Pyspark and Hadoop Distribution</h3><p>I love Python, it’s easy to use and straightforward and also my main language when developing Spark applications. When I first started using Pyspark, I encountered the issue where running python main.py would magically run my spark job without the need for a spark-submit. Then I tried to use an s3 connector to read a test file from s3</p><pre>spark = SparkSession \<br>    .builder \<br>    .config(&quot;spark.jars.packages&quot;,<br>            &quot;org.apache.hadoop:hadoop-aws:3.2.0&quot;,<br>            ) \...</pre><p>I thought that since I was using pyspark-3.0.1 and that spark-3.0.1 could be bundled for hadoop 3.2.0 and later versions, that that was the correct package to use. Alas, that is not the case. I am using pipenv to handle the python dependencies and when I checked the virtual environment that was created there was no hadoop 3.2 jars, only 2.7 jars.</p><p><strong>Outcome: </strong>Pyspark is a subset of all the spark libraries and does not have all the jars. You can think of it as a cool API that will interact happily with your cluster, but not feature complete enough to launch a cluster itself.</p><p>pyspark 3.0.1 which is as of writing this article is the most recent release version only contains hadoop 2.7 jars and thus cannot use more recent hadoop-aws packages (the one that contains the magic s3 connector). That should not be a real problem in production as you would have your desired Spark cluster running with the version you like, but for development, it can be confusing as by default SPARK_HOME would point to the pyspark distribution that was downloaded via pipenv.</p><p><strong>Solution: </strong>Download the latest spark distribution bundled with hadoop 3.2 and point that SPARK_HOME environment variable to where the folder was downloaded. Voila, now you can use the latest hadoop-aws packages</p><h3>Summary</h3><p>Apache Spark is an awesome tool that enabled the whole data engineering world to leap forward. That does not mean though that using Spark is in all cases trivial. And sometimes, the straightforward-looking things become the most difficult and confusing.</p><p>If you liked this article, click the 👏 so other people will see it here on Medium.</p><p><em>More content at </em><a href="http://plainenglish.io/"><em>plainenglish.io</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c91ba2d3978" width="1" height="1" alt=""><hr><p><a href="https://aws.plainenglish.io/demystifying-apache-spark-quirks-2c91ba2d3978">A Guide to Demystifying Apache Spark’s Quirks</a> was originally published in <a href="https://aws.plainenglish.io/">AWS in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>