<?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 Aakash Mandlik on Medium]]></title>
        <description><![CDATA[Stories by Aakash Mandlik on Medium]]></description>
        <link>https://medium.com/@aakashmandlik?source=rss-a79653bb049f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*FmY4VUkN8lObSurkyGADdw.jpeg</url>
            <title>Stories by Aakash Mandlik on Medium</title>
            <link>https://medium.com/@aakashmandlik?source=rss-a79653bb049f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 02:46:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@aakashmandlik/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[Reducing Data Platform Cost by $2M]]></title>
            <link>https://engineering.razorpay.com/reducing-data-platform-cost-by-2m-d8f82285c4ae?source=rss-a79653bb049f------2</link>
            <guid isPermaLink="false">https://medium.com/p/d8f82285c4ae</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[data-platforms]]></category>
            <category><![CDATA[big-data]]></category>
            <dc:creator><![CDATA[Aakash Mandlik]]></dc:creator>
            <pubDate>Wed, 21 Jun 2023 12:03:22 GMT</pubDate>
            <atom:updated>2023-06-21T12:03:22.262Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1INqICZUQkP_00nYBE5QIQ.png" /></figure><p>Welcome to the Razorpay technology blog! In this blog, we are primarily focusing on cost savings by the Data platform team.</p><p>We have some exciting news to share with you! Through our efforts to reduce costs, we successfully managed to cut down our platform expenses by approximately $2M per year.</p><p>In this blog, we will reveal the secrets behind our success and provide valuable insights into how we improved our operations, increased efficiency, and paved the way for a more sustainable and cost-effective future.</p><h3>High-level Data Platform architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*Qz67VHU58tXkBdl8yD9yng.png" /></figure><h4>Data Platform</h4><ul><li>We collect data from transactional aka OLTP systems like MySQL etc and push them to S3 via CDC pipelines. These CDC pipelines push the data to Kafka from Mysql via the Maxwell replicator.</li><li>Spark pipelines run every few minutes and read the latest data from Kafka and push it to S3 in parquet/delta-lake format. Also updates the event metadata.</li><li>We have <a href="https://engineering.razorpay.com/how-trino-and-alluxio-power-analytics-at-razorpay-803d3386daaf">Trino as a query engine</a>, which powers the majority of analytics at Razorpay.</li></ul><h4>Merchant Reporting</h4><ul><li>We have exposed a dashboard to the merchants, to download reports regarding transactions made for their platform via Razorpay.</li><li>We serve almost 10k reports daily to merchants.</li><li>Reports are basically data fetched from data-lake tables and provided in the required format to the merchant. The data read size can go to a few TBs as well.</li><li>Maintaining the data at scale and allowing reading of the data with the handling of spikes is a challenging task.</li></ul><h3>Cost Concerns</h3><p>As part of the cost optimisations initiative across the organisation in Razorpay, we calculated the cost of running the workloads and managing the platform. The total cost of operating the overall data platform was very high.</p><p>As it is visible from the picture below, the AWS and DBU cost for the data platform was increasing every month from August 2022 to December 2022. The major concern was to optimise the cost such that it does not increase again in future and be stable even without manual efforts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-BJSoG_nERTl9w5i" /></figure><p>Thus our main goal was to reduce the cost without affecting the availability, success metrics, and SLA guarantees.</p><h3>Identification Of Problems</h3><p>One of the trickiest things to identify is “<strong>where to start with cost optimisations?</strong>”. More often than not things are not being in an ideal way in the first place, so identifying and segregating is the first thing to do if that fits the use case. The scope of this section is just problem identification. We will go with the solutions to the problems in the next section.</p><p>The two major components where we started looking were:</p><h4>Storage</h4><p><strong>S3</strong></p><ul><li>S3 storage is generally cheap but that’s why most of us take it for granted.</li><li>We are using S3 for development, and testing data storage. The general behaviour was to run the testing and keep the S3 files in staging buckets without being used ever in the future.</li><li>Stakeholders check: We did reach out to stakeholders to see if they need the data for longer amounts of time or we can set any lifecycle policy to purge if the data is not being used.</li><li>Merchant reporting data locality: Merchant reporting data is served using denormalised(pre-joined) tables created on top of raw tables. Most of the queries on data-lake for merchant reporting are filtering data on merchant_id. There is no data localisation, such that one single file can contain data for various merchants in a non-orderly fashion. Thus reading only for one merchant would require reading all the files and doing shuffle and filters to get the required data.</li></ul><p><a href="https://aws.amazon.com/ebs/"><strong>EBS</strong></a><strong> savings</strong></p><p>Amazon Elastic Block Store (Amazon EBS) is an easy-to-use, scalable, high-performance block-storage service designed for Amazon Elastic Compute Cloud (Amazon EC2).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lc2tk72mNH4QASvE" /></figure><p><strong>How did we use it?</strong></p><ul><li>Jobs had been configured with EBS autoscaling on. Which means it can upscale and downscale multiple times while running a job.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/0*cb7I2lqnB1O1dpqh" /></figure><ul><li>Due to the above reason, jobs were scaling to more than what was actually required. For example, some jobs were scaling the EBS storage to 3 volumes of 100GB each, while the actual need was lesser.</li></ul><h4>Compute</h4><p><a href="https://en.wikipedia.org/wiki/Amazon_Elastic_Compute_Cloud"><strong>EC2</strong></a><strong> savings</strong></p><ul><li>For all the jobs, we analysed the cluster utilisation for both Memory and CPU for the whole run of the job.</li><li>We used ganglia metrics for this info. Ganglia metrics dashboard is provided for every job.</li><li>Ganglia dashboard shows us that the cluster configuration is bigger than necessary, by analysing the low use of memory, CPU, and a balanced server load distribution.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dm3fq6a51Z4AjxjD" /></figure><ul><li>It’s also possible to select any particular node and understand CPU and memory usage. For many applications, not all nodes are underutilised but few are. Many times a driver is underutilised while a worker isn’t and vice versa.</li><li>Merchant reporting generation happens via job clusters on Databricks with Spark as a processing engine. For each report request, new job clusters start from inception which requires instance negotiation + init-scripts initialisation. Additionally, it may take more time depending on the availability of EC2 instances in the region.</li></ul><p><strong>Workload optimisation</strong></p><ul><li>As part of merchant reporting, we also provide a way to directly query raw tables existing in the data lake, which is not queryable using denormalised tables.</li><li>There were many un-optimised queries due to a lack of filtering on partition columns in joined tables or unnecessary nested queries.</li></ul><h3>Reduce, Remove, Replace and Reuse</h3><p>We have bifurcated the solution into multiple parts i.e. Reduce, Remove, Replace, Reuse. Either we can reduce the infrastructure by reducing workers, remove the unused S3 objects, or we reuse the same cluster for running multiple jobs in sequence to reduce the cluster startup time or we can replace one instance type with another in Databricks.</p><p>Let’s look at each of these approaches.</p><h4>Storage</h4><p><strong>Remove unused stage objects</strong></p><p>Did a rigorous activity with the team to account for data lying on s3 Buckets, and categorised stale, and unaccounted data. This led to a data cleanup of around 300–400 GB. But what is stopping for this data to accumulate again?</p><p>Enter <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lifecycle-mgmt.html">Lifecycle</a>(LC) Policies and strict processes for staging and dev buckets. We set Lifecycle policies for most buckets that don’t allow data to go beyond a certain size and set a process for writing data on dev and staging buckets so that it comes under certain prefixes and with tags so that it is processed by the associated LC. We also checked that there were TBs of application logs written and after due diligence applied an LC policy for logs as well. <br>Total Savings by LC and deletion of stage data = <strong>~2PB</strong></p><p><strong>[Reduce] Data skipping while read of S3 objects by data reordering</strong></p><p>All of our reports have a date and merchant_id filters. For most of the reports, we use denormalized tables, to read and create the reports. These denormalized tables are partitioned on created_date. Thus date_filter optimization is already in place.</p><p>But we don’t have a partition for merchant_id, which is equally important. But there is a challenge in having another partition on merchant_id. Since merchant_id is a high cardinality column, hence partitioning on it is a very costly write operation.</p><p>So we went ahead with Zorder provided by Databricks.</p><p><a href="https://docs.databricks.com/delta/data-skipping.html#what-is-z-ordering"><strong>What is Z-ordering?</strong></a></p><p>Z-ordering is a <a href="https://en.wikipedia.org/wiki/Z-order_curve">technique</a> to colocate related information in the same set of files. This co-locality is automatically used by Delta Lake on Databricks data-skipping algorithms. This behaviour dramatically reduces the amount of data that Delta Lake on Databricks needs to read. To Z-order data, you specify the columns to order on in the Z-ORDER BY clause:</p><blockquote><em>OPTIMIZE events WHERE date &gt;= current_timestamp() — INTERVAL 1 day ZORDER BY (eventType)</em></blockquote><p>If you expect a column to be commonly used in query predicates and if that column has high cardinality (that is, a large number of distinct values), then use Z-ORDER BY.</p><p>For example, Delta Lake automatically maintains the min and max values for up to 32 fields in the delta table and stores those values as part of the metadata. By leveraging min-max ranges, Delta Lake is able to skip the files that are out of the range of the querying field values (Data Skipping). In order to make it effective, data can be clustered by Z-Order columns so that min-max ranges are narrow and, ideally, non-overlapping. To cluster data, run OPTIMIZE command with Z-Order columns.</p><blockquote><em>OPTIMIZE ENGAGEMENT_DATA Z-ORDER BY (EngagementDate)})</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*jwxFf9k9cX0Hl9zC" /></figure><p>Here in the above snap, we can see files having min_values and max_values for the engagement date. This helps filter out files which have filtering outside of the file’s range. Let’s say we have engagement_date = “2019_08_29” , then only the 2nd file will be read and the other two will be skipped.</p><p><strong>Benefits</strong></p><ul><li><strong>Reduced report creation time</strong>: Since a lot of files are skipped while reading the data from s3, the average report creation time is reduced by approximately 20%. Since the files are fewer, there are very few or no shuffles to get a single merchant’s data. Thus both input and shuffles are reduced. The cost has also been reduced by <strong>approximately 25%</strong>.</li><li><strong>Reduces cost on S3 GetObject and ListBucket operations: </strong>Files are skipped by reading the metadata, thus ListBucket and GetObject operations will be less. Therefore overall optimisation on the S3 API cost for these operations.</li></ul><h4>Computation</h4><p><strong>EBS Savings</strong></p><p>EBS autoscaling in Databricks overestimated the EBS volumes for the majority of workloads. Due to this, the majority of provisioned EBS volumes were underutilized leading to extra costs.</p><p>We <strong>reduced</strong> the EBS volume provisioning by disabling the “Enable autoscaling local storage” checkbox, we need to set what static EBS volume we need for the job.</p><p>Static EBS volume works for us because our jobs are light and only read a single denormalised table without any join. Thus shuffles are fewer too.</p><p><strong>EC2 Savings</strong></p><blockquote><em>“Few lost their fortunes in gambling, few in drinking, while a little few left their EC2 instance on”</em></blockquote><p>We run all our workloads on Ec2 instances. All the Databricks jobs or Trino clusters use Ec2 instances. As we have already seen how we identified the Ec2 saving opportunities, let’s look at how we actually implemented them.</p><p><strong><em>Reduce </em></strong><em>trino workers</em><strong><em> </em></strong><em>when no load</em></p><ol><li>We migrated all our Trino clusters to a multi-arch model, which helped us leverage <a href="https://aws.amazon.com/ec2/graviton/">graviton instances</a> to reduce infrastructure costs without affecting performance.</li><li>Apart from this, we also tweaked our autoscaling rules to be more aggressive during downscaling events to avoid resource wastage when there is no load, helping us save up further on compute costs.</li><li>Both these changes along with minor cluster capacity changes helped us reduce Trino Infrastructure costs by <strong>more than 60%</strong>.</li></ol><p><strong><em>Reduce </em></strong><em>the driver</em></p><ol><li>We reduced the driver size of report generation for Databricks spark jobs to half.</li><li>We reduced the driver from r5a.4xlarge to r5a.2xlarge.</li><li>This we did with information from Ganglia metrics.</li></ol><p><strong><em>Replace</em></strong><em> the memory-optimized instances with compute-optimized instances</em></p><ol><li>Merchant reporting workloads read single denormalized tables and do a lot of transformations to get the final desired result.</li><li>For this kind of use-case, we generally need compute-optimized instances.</li><li>Compute-optimized instances worked for us as they are more reasonable with the same CPU and less memory.</li></ol><p><strong><em>Reuse</em></strong><em> the clusters</em></p><ol><li>In the case of merchant reporting, we can keep a single job cluster for running more than one report run.</li><li>Thus a single job cluster can sequentially create 5 reports. This can help in reducing the total wait time of the EC2 instances by <strong>60%</strong>.</li><li>This also helps in reducing costs by a good amount.</li></ol><p><strong>Workload optimisation — Raw Queries</strong></p><ul><li>Raw Queries needed the addition of partition filters(created_date) for all the tables used in SQL query.</li><li>Removing useless nested sub-queries, and doing the heavy lifting as part of the common code.</li></ul><h3>Conclusion</h3><p>The Razorpay data team has come a long way in optimizing the total cost of operation. We have reduced and reused the infrastructure wherever applicable. We still want to optimize the cost even further and become the most optimal version of ourselves.</p><p>After the whole exercise of a few quarters, we ended up saving the overall cost of operation of the data platform by a good amount. We have many major learnings along the way and this is a small effort to share that with the world.</p><p>We would like to hear from you on what we can do more on our path to be the most optimal tech data platform available.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d8f82285c4ae" width="1" height="1" alt=""><hr><p><a href="https://engineering.razorpay.com/reducing-data-platform-cost-by-2m-d8f82285c4ae">Reducing Data Platform Cost by $2M</a> was originally published in <a href="https://engineering.razorpay.com/">Razorpay Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Facebook Interview Journey : Big-data Engineer | Singapore]]></title>
            <link>https://medium.com/@aakashmandlik/facebook-interview-journey-big-data-engineer-f93b6fef004c?source=rss-a79653bb049f------2</link>
            <guid isPermaLink="false">https://medium.com/p/f93b6fef004c</guid>
            <category><![CDATA[facebook]]></category>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[data-structures]]></category>
            <dc:creator><![CDATA[Aakash Mandlik]]></dc:creator>
            <pubDate>Sat, 04 Aug 2018 05:05:25 GMT</pubDate>
            <atom:updated>2019-06-09T04:21:16.383Z</atom:updated>
            <content:encoded><![CDATA[<p>I am pretty excited to tell you the journey which has given me the most enriching experience of my life. The story begins with a call from a bizarre number. It left me in shock for a second but I picked the call. It was from an HR who introduced herself as Facebook’s HR personnel. I got an idea but was unsure of the biggest opportunity that was knocking on the door. After this I introduced myself with brief details of my projects and interest areas.</p><blockquote><strong>Round 1</strong></blockquote><p>The interviewer was very sweet and made me comfortable. She told me how she found my resume relevant to their big data profile. A series of around 10 questions related to Data structures, statistics, Java, Sql were asked. These were very basic questions but left me thinking about them afterwards.</p><p><strong>Result</strong>: I got a mail after 3–4 days regarding the feedback. The feedback was positive. I got a chilling feel with faster heart beats already. She provided the details for the next interview (interviewer’s name and link to communicate with him). It was a <a href="http://coderpad.io/">coderpad.io</a> link. She also provided enough practice/study material to prepare for the interview. It contained material covering all the topics like data structures, competitive coding, SQL, data warehousing concepts, and big data architectural questions. I engrossed myself in this study material and hoped for the best. I began to give my 100% to the preparation after office hours. Preparing for the interview was not difficult as it was a very refreshing experience of coding my ass off.</p><blockquote><strong>Round 2</strong></blockquote><p>It started with a weird issue of microphone at my end. After resolving the issue, we were left with only 35 minutes for the interview. Without any more time wastage, the first question was asked which was a competitive coding question (Medium level). Solved it. The second question was also a coding question only, solved that too. After this SQL questions were started. He provided me with a sample database to refer to while solving the problems. This section contained around 3 questions. Solved all of them, albeit a little delay in the last one. After the interview, he seem impressed by my approaches.</p><p><strong>Result</strong> : The feedback was positive. They asked for suitable day for the next set of interviews in Singapore. I was flabbergasted. I started to look for free slots with consideration of Visa application and processing time too. This time also they provided some more study material, with a higher focus on data/code architectural point of view. I prepared day in and day out for it. That was the most exciting time of my life with lot of new things learnt. The next two weeks flew by in excitement. It was my first journey to a foreign nation and thus I was nervous for multiple reasons. Bon voyage…. They provided me with all the facilities- return flights with a stay of 3 days. My journey started at 9:00 in the morning, and reached Singapore by 6:30 in the evening. Later I checked into my hotel room by 8:30 and revised a few things to gain confidence (Although last moment revision never works in Facebook interviews). Managed a sound sleep in the night to keep the stamina up for the next day.</p><blockquote><strong>Round 3</strong></blockquote><p>I reached the Facebook office at 9:00AM in the morning. It was at a walking distance from the hotel. The receptionist helped me sign in for interview process and later an HR personnel of the Singapore office helped me to enter into the main area of the company. She made me comfortable by talking about my journey etc. The interview started in a conference room with the interviewee on webcam from some other office. He gave me a coding exercise to work upon with a platform to code and a white-board/marker for logic exercises. He also gave me some hints regarding the question. A few more discussions happened in between, and an hour later he asked me to explain the code. I took the help of the white-board and marker to explain. He seemed impressed.</p><blockquote><strong>Round 4</strong></blockquote><p>It was more of a technical SQL+Data warehousing concepts round. The interviewer was very cool. She made me comfortable by giving hints to dig deeper into the discussion. The white board was the medium for the whole interview. The questions were of moderate level. Solving regular SQL in office time served me good. Overall, the interview was good. I just did a mistake of solving before understanding the whole question, which wasted some of the precious time.</p><blockquote><strong>Round 5</strong></blockquote><p>This was the most interesting round. It revolved around coding and algorithms. The first question was a moderate level question but with complex edge cases. The catch was to track those in given time. I solved the question using two approaches, one with lesser complexity. The second question was a little complex. Hints from time to time helped me a lot while solving this question. I provided brute force approach in the beginning which helped me to optimize it further (if the problem is complex, brute force solution is like a tiny ray of sunlight in a cave). He looked skeptical.</p><blockquote><strong>Round 6</strong></blockquote><p>This was a very productive round. It involved data architecture questions. The interview started on a webcam. He started with a scenario to look upon. I analyzed the problem as he was explaining. He than started with how the whole architecture can be designed. I gave a good solution with a number of cases where it could go wrong. He then started with each edge case and drilled further into it. Talk of complexity was also discussed which can be a prime reason for choosing or not choosing the architectural design. Then he drilled towards the scaling of the design infrastructure in cases of hotspots and higher hits on pages. This interview ended with an open ended solution, which is the beauty of data/technical architectural interviews.</p><blockquote><strong>Round 7</strong></blockquote><p>This was the final round, more of behavioral round. The interviewer asked me different questions around the day to day life and office routine. He asked me questions around the projects I had done. Few questions were basic behavioral questions like what are your strengths, what are your weaknesses. He also asked some project related questions like what is the most interesting project, what was the most challenging thing you did in the project, what was your contribution to the team, what you did for which you were praised, were there any differences of opinions of any type with you manager and how you confronted yourself. After the interview was over, interviewer helped me walk out of their office in a polite manner. After the interview I returned to the hotel accommodation. It was about 5PM in the evening. My flight was next day at 7PM. So I got full 1 day for travelling around Singapore and I did the same. After a week I got the result. The result was not positive. They didn’t provide a feedback as such. But I figured the reasons and things which could have wrong at that time, and I worked upon them. Retrospection plays a very important part in one’s growth.</p><blockquote><strong>Final Result:</strong></blockquote><p>I was not selected but the experience was enriching and provided a better understanding about the whole process.</p><p>PS: Please follow me to keep in touch with big data technologies,algorithms, data structures, data science, SQL, business intelligence etc. Also please provide honest feedback, which helps to improve the communication.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f93b6fef004c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>