# HackerEarth

Blog about engineering and technology at HackerEarth.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## Computing accurate skill percentile with DDSketch

DevFeed: [Computing accurate skill percentile with DDSketch](<https://devfeed.tech/articles/computing-accurate-skill-percentile-with-ddsketch-20019.md>)

Original publisher: [Read original article](<http://engineering.hackerearth.com/2023/09/17/building-a-relaible-global-benchmarking-platform/>)

Published: 2023-09-17T00:00:00Z

Content type: article

Language: en

Sources: [HackerEarth](<https://devfeed.tech/sources/hackerearth.md>)

Topics: [Algorithms, Complexity](<https://devfeed.tech/topics/algorithms-complexity.md>), [benchmarking](<https://devfeed.tech/topics/benchmarking.md>), [data](<https://devfeed.tech/topics/data.md>), [Data structures](<https://devfeed.tech/topics/data-structures.md>), [real-time](<https://devfeed.tech/topics/real-time.md>)

Tags: [algorithms](<https://devfeed.tech/tags/algorithms.md>), [analysis](<https://devfeed.tech/tags/analysis.md>), [benchmark](<https://devfeed.tech/tags/benchmark.md>), [benchmarking](<https://devfeed.tech/tags/benchmarking.md>), [benchmarks](<https://devfeed.tech/tags/benchmarks.md>), [complexity](<https://devfeed.tech/tags/complexity.md>), [data](<https://devfeed.tech/tags/data.md>), [flow](<https://devfeed.tech/tags/flow.md>), [pipeline](<https://devfeed.tech/tags/pipeline.md>), [real-time](<https://devfeed.tech/tags/real-time.md>), [space](<https://devfeed.tech/tags/space.md>)

### AI overview

This article explains how HackerEarth built a global benchmarking platform for candidate skill percentiles. It replaced a cron-based, deterministic approach with data ingestion and read flows using probabilistic algorithms, especially DDSketch, to estimate quantiles from compressed data. The article compares DDSketch with T-Digest using accuracy, time, and space complexity analyses.

### Source excerpt

Introduction HackerEarth has lots of candidates getting evaluated on a daily basis. We have a feature that benchmarks candidates across the platform. Benchmarking is the process of creating the profile of the ideal candidate for a position, and then measuring all candidates against that profile. To benchmark candidate skills against our millions of candidates, we decided to move away from our regular cron solution to build a more reliable and accurate data pipeline. To support this, we created a new data ingestion flow and data read flow. We moved away from our deterministic algorithms to probabilistic algorithms with DDSketch. Problem Our old benchmarking solution was trying to compute the global benchmarking of a candidate on the fly by calculating the solve percentage of the individual skills and returning the geometric mean of all the skill benchmarks. We handle huge volumes of data every day. Analyzing this data itself--for example, calculating a quantile was optimal in terms of resources. Solution We came up with a solution that computes an approximate quantile from a compressed representation of that data. We first need to appropriately summarize that data without incurring an excessive loss of fidelity. We do this by creating a sketch. Sketch algorithms generate sketches: smaller, more manageable data structures, from which we can calculate some properties of the original data. We considered various algorithms to accurately compute percentiles on noisy, large-scale, real-time data that we were receiving from candidates' skill scores. We considered using Tdigest and DDSketch. For our use case, DDSketch served the purpose.We did a POC and compared the accuracy of both the algorithms as shown below to come up with a finalized algorithm. POC results and observations We compared the actual percentile ranges in comparison to the two probabilistic approaches we mentioned(DDSketch and T-DIgest), and these were the results. Note: we have run these tests on the random

## Logging millions of requests reliably with our new data ingestion pipeline

DevFeed: [Logging millions of requests reliably with our new data ingestion pipeline](<https://devfeed.tech/articles/logging-millions-of-requests-reliably-with-our-new-data-ingestion-pipeline-20018.md>)

Original publisher: [Read original article](<http://engineering.hackerearth.com/2022/07/01/logging-millions-of-requests-reliably-with-our-new-data-ingestion-pipeline/>)

Published: 2022-07-01T00:00:00Z

Content type: article

Language: en

Sources: [HackerEarth](<https://devfeed.tech/sources/hackerearth.md>)

Topics: [Logging](<https://devfeed.tech/topics/logging.md>), [Amazon Redshift](<https://devfeed.tech/topics/amazon-redshift.md>), [log management](<https://devfeed.tech/topics/log-management.md>), [real-time](<https://devfeed.tech/topics/real-time.md>), [Amazon Web Services](<https://devfeed.tech/topics/aws.md>), [cloud-infrastructure](<https://devfeed.tech/topics/cloud-infrastructure.md>), [web applications](<https://devfeed.tech/topics/web-applications.md>), [Security](<https://devfeed.tech/topics/security.md>), [Architecture & Design](<https://devfeed.tech/topics/architecture-design.md>)

Tags: [analytics](<https://devfeed.tech/tags/analytics.md>), [aws](<https://devfeed.tech/tags/aws.md>), [infrastructure](<https://devfeed.tech/tags/infrastructure.md>), [logging](<https://devfeed.tech/tags/logging.md>), [pipeline](<https://devfeed.tech/tags/pipeline.md>), [real-time](<https://devfeed.tech/tags/real-time.md>), [redshift](<https://devfeed.tech/tags/redshift.md>), [security](<https://devfeed.tech/tags/security.md>), [server](<https://devfeed.tech/tags/server.md>)

### AI overview

HackerEarth describes redesigning its request-logging architecture to reliably ingest millions of HTTP/HTTPS requests in near real time. The new pipeline uses Kinesis Firehose data streams to deliver compressed and encrypted data from web servers to Amazon Redshift, reducing operational overhead and infrastructure cost while providing retries and delivery within 10-15 minutes.

### Source excerpt

Introduction HackerEarth handles millions of requests every day. To understand the user access patterns, get the usage of any particular feature or a page, figure out the daily active users or users who have been active for the past 6 months, etc in near real time, it is important to stream that data from across different services and ingest it to the analytics pipeline reliably. Problem Our old request logging architecture was complex and has many moving components. There were a lot of operational overheads involved in maintaining and scaling each of those components independently to ensure that all the self-hosted components were up and running all the time. Architecture Solution Last year, we revamped the way we log our web requests. It was done mainly to increase the reliability in logging the HTTP/HTTPS request data from across web services and also to reduce the operational overheads and the infrastructure cost associated with it. The new flow is making use of Kinesis Firehose data streams to deliver the request data from our web servers to Redshift (the database that we use to log and query request data) reliably with much lower cost. Amazon Kinesis Firehose is a fully managed service that automatically scales to match the throughput of our incoming request log data and requires no ongoing administration. It also allows us to compress and encrypt the data before loading it, minimizing the amount of storage used at the destination with increased security and we only need to pay for the amount of data we transmit through the service. The new flow is a fully managed solution with almost no operational overhead. We tried to keep the flow simple and straightforward with less number of moving components. The request data is now guaranteed to appear in the Redshift table within 10-15 minutes from the point we received a request at our web server's end. There are retries configured between consecutive infra components in the new flow to make sure there are no message

## Building a reliable asynchronous job pipeline

DevFeed: [Building a reliable asynchronous job pipeline](<https://devfeed.tech/articles/building-a-reliable-asynchronous-job-pipeline-20017.md>)

Original publisher: [Read original article](<http://engineering.hackerearth.com/2022/06/17/building-a-reliable-asynchronous-job-pipeline/>)

Published: 2022-06-17T00:00:00Z

Content type: article

Language: en

Sources: [HackerEarth](<https://devfeed.tech/sources/hackerearth.md>)

Topics: [Amazon Simple Queue Service (SQS)](<https://devfeed.tech/topics/amazon-simple-queue-service-sqs.md>), [Library](<https://devfeed.tech/topics/library.md>), [Scalability](<https://devfeed.tech/topics/scalability.md>), [web applications](<https://devfeed.tech/topics/web-applications.md>), [Architecture & Design](<https://devfeed.tech/topics/architecture-design.md>), [Amazon Web Services](<https://devfeed.tech/topics/aws.md>), [Amazon S3](<https://devfeed.tech/topics/amazon-s3.md>), [Serverless](<https://devfeed.tech/topics/serverless.md>), [Provisioning](<https://devfeed.tech/topics/provisioning.md>), [Security](<https://devfeed.tech/topics/security.md>), [Kafka](<https://devfeed.tech/topics/kafka.md>), [Self-hosted](<https://devfeed.tech/topics/self-hosted.md>)

Tags: [applications](<https://devfeed.tech/tags/applications.md>), [architecture](<https://devfeed.tech/tags/architecture.md>), [aws](<https://devfeed.tech/tags/aws.md>), [infrastructure](<https://devfeed.tech/tags/infrastructure.md>), [jobs](<https://devfeed.tech/tags/jobs.md>), [kafka](<https://devfeed.tech/tags/kafka.md>), [libraries](<https://devfeed.tech/tags/libraries.md>), [open-source](<https://devfeed.tech/tags/open-source.md>), [pipeline](<https://devfeed.tech/tags/pipeline.md>), [provisioning](<https://devfeed.tech/tags/provisioning.md>), [s3](<https://devfeed.tech/tags/s3.md>), [scalability](<https://devfeed.tech/tags/scalability.md>), [security](<https://devfeed.tech/tags/security.md>), [serverless](<https://devfeed.tech/tags/serverless.md>)

### AI overview

The article presents he-messenger, a custom serverless library for reliable asynchronous background-job processing. Built on AWS SQS, SNS, and S3, it replaces a self-hosted RabbitMQ and Kafka solution to reduce operational overhead, improve security, and support scalable service-to-service communication.

### Source excerpt

Asynchronous background jobs can dramatically improve the performance and scalability of web applications by offloading resource-intensive and time consuming processing from the request-response cycle of an application. Last year, in an effort to make our asynchronous flows more reliable, secure, and scalable, we decided to move away from our self-hosted solution that was based on RabbitMQ and Kafka, to a fully-managed one. This was done mainly to reduce the operational overheads in managing and scaling the underlying infrastructure and also to improve our overall security posture. To support this flow, we created a new library called he-messenger that implements an end-to-end queuing solution for allowing different services or different components of the same service to communicate with each other asynchronously. This library is built on top of the SQS, SNS, and S3 - managed services provided by AWS. It is a fully serverless solution that ingests events from different services, buffers them, and then delivers those events to the subscribed services in a reliable way. It simplifies the otherwise laborious process of provisioning and scaling self-hosted infrastructure. Since its introduction, this library has become one of the critical pieces of our architecture powering a lot of different use-cases with a very high number of transactions There are many open-source libraries available in the market that use AWS managed services to support asynchronous background jobs. However, none of them offered an end-to-end solution and the kind of guarantees we needed. Therefore, we decided to implement our own custom library to support this flow. The purpose of this blog is to give you an overview of the internal and the code level details of the he-messenger library along with a sample reference architecture, supported flows, features,and benefits of this solution. Terminology Channel: An abstract communication layer responsible for passing messages between producers and consu

## How to set a React Component or dom element as a background image

DevFeed: [How to set a React Component or dom element as a background image](<https://devfeed.tech/articles/how-to-set-a-react-component-or-dom-element-as-a-background-image-20016.md>)

Original publisher: [Read original article](<http://engineering.hackerearth.com/2021/08/12/how-to-set-a-react-component-as-a-background-image/>)

Published: 2021-08-12T00:00:00Z

Content type: tutorial

Language: en

Sources: [HackerEarth](<https://devfeed.tech/sources/hackerearth.md>)

Topics: [React](<https://devfeed.tech/topics/react.md>), [Document Object Model (DOM)](<https://devfeed.tech/topics/dom.md>), [Code](<https://devfeed.tech/topics/code.md>), [Front end](<https://devfeed.tech/topics/frontend.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [container](<https://devfeed.tech/tags/container.md>), [frontend](<https://devfeed.tech/tags/frontend.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [react](<https://devfeed.tech/tags/react.md>), [react-component](<https://devfeed.tech/tags/react-component.md>), [z-index](<https://devfeed.tech/tags/z-index.md>)

### AI overview

A step-by-step tutorial for displaying a React Component as a background-like layer behind a textarea. It uses a relatively positioned wrapper, an absolutely positioned component, a transparent textarea background, a negative z-index, and disabled pointer events on the component.

### Source excerpt

During my internship at HackerEarth, I faced an interesting problem. This blog is about that and how I solved it. Problem: To set a background image to the textarea element. My initial impression on seeing the design was that it would be easy. I thought it's a image but after exploring the code I came to know that it's not an image that we have to show as background instead, it's a React Component. So now what? To solve this problem we need to think from scratch. Solution: First, we will think about how to do it and then will implement it step by step. 1. Think From Scratch In this example, as you can see the content in the body element overlap the background-image. To solve this problem we just need to overlap the React Component with the textarea. 2. Implementation Create a textarea and React Component which we are going to use. The text area is to the left and to the right is the React Component which we are going to set as a background image in the textarea element. Steps: 1.Create a div which wrap textarea and React Component. Set the div position: relative and React Component position: absolute, top: 0 & left: 0. <div className="editor-container"> // position: relative <textarea className="editor"/> <BackGround /> // position: absolute; top: 0; left: 0; </div> 2.To overlap textarea on React component we need to set React Component z-index: -1. .bg-img { position: absolute; top: 0; left: 0; width: 250px; font-family: monospace; text-align: center; color: rgba(0, 0, 0, 0.29); z-index: -1; } As you can see we have a problem now. React Component is below the textarea and we are not able to see. 3.To solve the problem we need to make the textarea background transparent. But then if you click on the React Component you won't be able to edit the textarea. To solve this set pointer-events: none. .editor { height: 400px; width: 400px; background: rgba(0, 0, 0, 0); // background transparent } .bg-img { position: absolute; top: 0; left: 0; width: 250px; font-family: mono

## Zero to One and Beyond: HackerEarth's journey to Continuous Delivery

DevFeed: [Zero to One and Beyond: HackerEarth's journey to Continuous Delivery](<https://devfeed.tech/articles/zero-to-one-and-beyond-hackerearth-s-journey-to-continuous-delivery-20015.md>)

Original publisher: [Read original article](<http://engineering.hackerearth.com/2021/08/01/CI-CD-Journey/>)

Published: 2021-08-01T00:00:00Z

Content type: article

Language: en

Sources: [HackerEarth](<https://devfeed.tech/sources/hackerearth.md>)

Topics: [CI/CD](<https://devfeed.tech/topics/cicd.md>), [Continuous Delivery (CD)](<https://devfeed.tech/topics/continuous-delivery.md>), [Continuous Deployment (CD)](<https://devfeed.tech/topics/continuous-deployment.md>), [ci](<https://devfeed.tech/topics/ci.md>), [Deployment](<https://devfeed.tech/topics/deployment.md>), [Agile](<https://devfeed.tech/topics/agile.md>)

Tags: [agile](<https://devfeed.tech/tags/agile.md>), [ci](<https://devfeed.tech/tags/ci.md>), [ci-cd](<https://devfeed.tech/tags/ci-cd.md>), [code](<https://devfeed.tech/tags/code.md>), [continuous-delivery](<https://devfeed.tech/tags/continuous-delivery.md>), [continuous-deployment](<https://devfeed.tech/tags/continuous-deployment.md>), [deployment](<https://devfeed.tech/tags/deployment.md>)

### AI overview

HackerEarth describes its journey from frequent but failure-prone deployments toward continuous delivery and continuous deployment. The article explains how continuous integration, fast feedback near the point of failure, deployable software, and on-demand push-button deployments can improve release cadence and reduce costly production issues.

### Source excerpt

"Hey the deployment is broken again. Can you push this change again" "Hey, I merged my changes were merged in the morning. I still don't see them in production yet" "Argh, the static files are not updated. We have to run deployment again" These voices hollared across the hallway and this was followed by a huddle to sort things out. These voices soon grew louder and then we realised: Our Deployment is broken. Epilogue At HackerEarth, we have always been good at embracing bleeding edge technologies. We have always taken pride at doing what is right and acknowledge when something needs a fix. A faster delivery cadence and a quicker release cycle are very important for a startup of our scale. Our deployment related problems threatened our fundament need - "Pace" This prompted us to not just fix what was broken but to introduce a new paradigm to deployment - Continuous Deployment. The key tenets of following agile to push consistent smaller pieces of software frequently to customers and get Feedback. As any growing team, we were at one point struggling with - higher deployment failures or critical issues leaking to production. What followed was our path to redemption Circa 2019, HackerEarth was already doing frequent deployments. We had a process to collect, merge, tag and release code into production. But, this was not enough. As it must be obvious now, our feedback cycle was not close to the point of failure. The Integration happened closer to production and any failure is now expensive to fix. This is where our journey up the CI-CD ladder begun. You're doing continuous delivery when: Your software is deployable throughout its lifecycle Your team prioritises keeping the software deployable over working on new features Anybody can get fast, automated feedback on the production readiness of their systems any time somebody makes a change to them You can perform push-button deployments of any version of the software to any environment on demand" -- Martin Fowler When it all

## How I built my first search component in React

DevFeed: [How I built my first search component in React](<https://devfeed.tech/articles/how-i-built-my-first-search-component-in-react-20014.md>)

Original publisher: [Read original article](<http://engineering.hackerearth.com/2020/07/17/how-i-built-my-first-search-component/>)

Published: 2020-07-17T00:00:00Z

Content type: tutorial

Language: en

Sources: [HackerEarth](<https://devfeed.tech/sources/hackerearth.md>)

Topics: [React](<https://devfeed.tech/topics/react.md>), [Redux](<https://devfeed.tech/topics/redux.md>), [Development](<https://devfeed.tech/topics/development.md>), [Document Object Model (DOM)](<https://devfeed.tech/topics/dom.md>)

Tags: [architecture](<https://devfeed.tech/tags/architecture.md>), [caching](<https://devfeed.tech/tags/caching.md>), [code](<https://devfeed.tech/tags/code.md>), [components](<https://devfeed.tech/tags/components.md>), [modal](<https://devfeed.tech/tags/modal.md>), [module](<https://devfeed.tech/tags/module.md>), [react](<https://devfeed.tech/tags/react.md>), [redux](<https://devfeed.tech/tags/redux.md>), [render](<https://devfeed.tech/tags/render.md>), [search](<https://devfeed.tech/tags/search.md>), [server](<https://devfeed.tech/tags/server.md>)

### AI overview

A developer explains how they built a React search component for a donation platform. The component displays search results in a modal, uses Redux actions, reducers, and a store to manage state, and relies on a service layer for server requests, caching, and error handling.

### Source excerpt

In 2016, I was working to build a platform to help NGOs raise donations. The platform was supposed to be built using React. The beautiful designs were in place. I was excited to build some new features as well as to try out the new architecture using Redux on a larger scale. Yes, this was the time when Redux was fairly new. React still had PropTypes package attached to its core. The lifecycle method componentWillReceiveProps used to dominate the scene. Out of the many design components that I worked while building that platform, I am going to discuss my first search component in React here. Elements of a search bar The search bar was a simple input field placed at the middle of the main header. The design idea was to have a search component which displays results as soon as the user inputs something in it. Then, to provide a simple cross icon at the right end of the input field to clear the inputs and hide the search results. The search results were supposed to appear inside a modal starting below the main header of the site. Below are the designs to help you visualise things better: If you typed on the search bar, a search results component appeared and showed NGOs, Live Projects and Campaigns. Development Redux Architecture While building apps using Redux architecture, one should be cognizant of its three principles (Single source of truth, State is read-only and Changes are made with pure functions). In computer programming, a pure function is a function that has the following properties: Its return value is the same for the same arguments Its evaluation has no side effects In our case, a single module (file) was created to include action types, reducers and action creators. The flow was - when the user inputs something in the search field, we will take that value and pass it through an action creator which will fetch the results from the server for the queried string and return an action type along with the result. There was also a service layer in the middle, w

## Hassle-free automated assessments

DevFeed: [Hassle-free automated assessments](<https://devfeed.tech/articles/hassle-free-automated-assessments-20013.md>)

Original publisher: [Read original article](<http://engineering.hackerearth.com/2020/02/02/hassle-free-automated-assessments/>)

Published: 2020-02-02T00:00:00Z

Content type: article

Language: en

Sources: [HackerEarth](<https://devfeed.tech/sources/hackerearth.md>)

Topics: [ui](<https://devfeed.tech/topics/ui.md>), [Front end](<https://devfeed.tech/topics/frontend.md>), [Web Development](<https://devfeed.tech/topics/web-development.md>), [CSS](<https://devfeed.tech/topics/css.md>), [HTML](<https://devfeed.tech/topics/html.md>), [JavaScript](<https://devfeed.tech/topics/javascript.md>), [SQL](<https://devfeed.tech/topics/sql.md>), [Java](<https://devfeed.tech/topics/java.md>), [React](<https://devfeed.tech/topics/react.md>)

Tags: [cognitive-load](<https://devfeed.tech/tags/cognitive-load.md>), [css](<https://devfeed.tech/tags/css.md>), [customers](<https://devfeed.tech/tags/customers.md>), [design](<https://devfeed.tech/tags/design.md>), [enterprise](<https://devfeed.tech/tags/enterprise.md>), [java](<https://devfeed.tech/tags/java.md>), [javascript](<https://devfeed.tech/tags/javascript.md>), [react](<https://devfeed.tech/tags/react.md>), [sql](<https://devfeed.tech/tags/sql.md>), [ui](<https://devfeed.tech/tags/ui.md>)

### AI overview

The article describes HackerEarth's redesign of its automated assessment test-creation flow. It explains problems with the older profile-driven, complex, rigid, and limited interface, then presents a skill-driven, scalable flow designed for enterprise talent acquisition teams and non-technical test administrators. The redesign emphasizes minimal UI, lower cognitive load, improved flexibility, and support for varied skills, difficulties, and question types.

### Source excerpt

Our older test creation flow had several inherent problems associated with it: 1. Profile driven Earlier to this, we had test creation based on job profiles (role-based), which was restrictive as the skills were tightly coupled to the roles and were not customizable by the recruiters. For example, I could select a profile say front-end engineer and the questions generated will only be from HTML, CSS and Javascript. So, if a recruiter wanted to generate questions for a front-end engineer profile to test React skill, they had to add them manually from our questions library or theirs. 2. Complex UI The older interface was filled with unwanted form elements and had almost no provision to support newer question types. We somehow missed to provide a scalable and an intuitive step-by-step test creation flow that catered to the needs of our non-technical recruiters. 3. Rigid algorithm The algorithm we used for selecting the test questions was relatively rigid, so there was a limited scope in picking questions from a mix of skills and of varied difficulties, either from the HackerEarth's questions library or from the company's library or both. 4. Restricted question types Though there was a demand from our customers to include additional question types such as SQL, front-end project and Java project questions to the test creation flow, we could not accommodate them as the interface was already bloated. Your browser does not support the video tag. Design Based on the customer feedback and research data, it was important for us to improve the old flow in accord to the correct persona of our users. More focus was put on enterprise talent acquisition teams. We found out that in general scenario, such teams are bound by the following: Want - To hire good people with minimum effort and time Capabilities - Familiar with the technical terms and the skills needed for a role Limitations - Have low technical knowledge The new design was implemented keeping in mind all the requirements

## Profiling Django views with Scooby profiler

DevFeed: [Profiling Django views with Scooby profiler](<https://devfeed.tech/articles/profiling-django-views-with-scooby-profiler-20012.md>)

Original publisher: [Read original article](<http://engineering.hackerearth.com/2018/09/20/profiling-django-views-with-scooby/>)

Published: 2018-09-20T00:00:00Z

Content type: article

Language: en

Sources: [HackerEarth](<https://devfeed.tech/sources/hackerearth.md>)

Topics: [Django](<https://devfeed.tech/topics/django.md>), [debug](<https://devfeed.tech/topics/debug.md>), [Chrome extension](<https://devfeed.tech/topics/chrome-extension.md>), [Redis](<https://devfeed.tech/topics/redis.md>), [Ajax](<https://devfeed.tech/topics/ajax.md>), [npm](<https://devfeed.tech/topics/npm.md>), [Python](<https://devfeed.tech/topics/python.md>), [Front end](<https://devfeed.tech/topics/frontend.md>), [HTTP](<https://devfeed.tech/topics/http.md>)

Tags: [backend](<https://devfeed.tech/tags/backend.md>), [chrome](<https://devfeed.tech/tags/chrome.md>), [chrome-extension](<https://devfeed.tech/tags/chrome-extension.md>), [debug](<https://devfeed.tech/tags/debug.md>), [django](<https://devfeed.tech/tags/django.md>), [front-end](<https://devfeed.tech/tags/front-end.md>), [http](<https://devfeed.tech/tags/http.md>), [npm](<https://devfeed.tech/tags/npm.md>), [profiling](<https://devfeed.tech/tags/profiling.md>), [python](<https://devfeed.tech/tags/python.md>), [redis](<https://devfeed.tech/tags/redis.md>), [web](<https://devfeed.tech/tags/web.md>)

### AI overview

This article introduces Scooby, a Django and Python profiling package designed to inspect SQL and other plugin statistics for AJAX requests. It stores profiling data temporarily in Redis and exposes the results through a Chrome extension, avoiding the performance costs of injecting statistics into rendered HTML.

### Source excerpt

Earlier in 2016, I came up with the idea of creating a Python module which could provide functionality of profiling functions w.r.t. SQL queries and tell exactly at what lines of function, the queries were happening. I called that package Goofy and created it with the engineering of Python AST manipulation. You can read the post on it here later. It helped us profiling views serving AJAX requests but it had some limitations too. E.g. we couldn't see the whole callstack trace of the queries and couldn't analyze the queries. In an internal hackathon @HackerEarth which happened in Nov 2017, I revisited this problem and tried to come up with a profiler, through which we could see the stats on front-end and which should be much lightweight and would work with AJAX requests. I named this package Scooby. Idea We have been using the package django-debug-toolbar, but it wasn't enough because it didn't have the functionality of profiling AJAX requests. And because of the size of our codebase, it had made serving web pages slower in develop mode because it injects the stats in HTML by rendering and rendering takes time. So we needed an alternative. The idea while creating the Scooby package was to have a similar type of package as of django-debug-toolbar but instead of rendering the stats to HTML, we can dump the stats data to some backend store e.g. Redis where it will reside temporarily. And show the stats on front-end using a chrome extension. Implementation We had to create a Python/Django package for backend and a npm package for front-end which would build the chrome-extension. We took the decision of using ReactJS as rendering framework for the chrome-extension. In backend, we just had to create and put a new middleware which will do the job of collecting profiled stats for different plugins (E.g. SQL, Memcache etc.) and put the stats to Redis against some UUID as key. We would put that key as value of a custom header (X-Scooby) in HTTP response, so that chrome-extensio

## What you see is what you get!

DevFeed: [What you see is what you get!](<https://devfeed.tech/articles/what-you-see-is-what-you-get-20011.md>)

Original publisher: [Read original article](<http://engineering.hackerearth.com/2018/07/19/what-you-see-is-what-you-get/>)

Published: 2018-07-19T00:00:00Z

Content type: article

Language: en

Sources: [HackerEarth](<https://devfeed.tech/sources/hackerearth.md>)

Topics: [Django](<https://devfeed.tech/topics/django.md>), [Markdown](<https://devfeed.tech/topics/markdown.md>), [Open Source](<https://devfeed.tech/topics/open-source.md>), [Stack Overflow](<https://devfeed.tech/topics/stackoverflow.md>), [Google Search](<https://devfeed.tech/topics/google-search.md>)

Tags: [comparison](<https://devfeed.tech/tags/comparison.md>), [developer](<https://devfeed.tech/tags/developer.md>), [django](<https://devfeed.tech/tags/django.md>), [google-search](<https://devfeed.tech/tags/google-search.md>), [markdown](<https://devfeed.tech/tags/markdown.md>), [open-source](<https://devfeed.tech/tags/open-source.md>), [search](<https://devfeed.tech/tags/search.md>), [software](<https://devfeed.tech/tags/software.md>)

### AI overview

HackerEarth replaced a Markdown editor in its Recruiter Dashboard with CKEditor 4, a WYSIWYG rich-text editor, to make content creation easier for recruiters. The article explains the reasons for choosing CKEditor over TinyMCE and describes its integration into the Django-based Recruit platform.

### Source excerpt

Introduction HackerEarth has grown into a platform that serves a huge number of customers for technical assessment. To make this possible, we try our best to make the platform as easy-to-use as it can get. At several places in our Recruiter Dashboard, we used to have a Markdown editor to allow users to edit free text. There have been multiple times when many of our recruiters have struggled to create content using the Markdown editor. They need not to worry anymore. After many such requests to improve this, we came up with a fix. Say hello to CKEditor (version 4)--The well-known WYSIWYG, Rich Text editor. Why CKEditor? In the battle of the titans (of WYSIWYG editing) between CKEditor and TinyMCE, we decided to go with CKEditor because of the following reasons: It has a huge community of active developers. The strength of the community around an open source project is strongly related to the project's success. As compared to TinyMCE, it provides better support for the following: Multiple languages Source editing Tables Image and media handling etc. It was designed with modularity in mind which allows you to go much deeper if you're a developer. It is doing much better as compared to TinyMCE. One of the easy tricks while surveying software is to compare how alternatives are doing on Google and Stack Overflow trends. Google search comparison (past 5 years) Number of Stack Overflow questions asked Integration The integration of WYSIWYG editor across HackerEarth's Recruit platform is broadly divided into three steps: Adding the Django CKEditor package As the Recruiter dashboard is written entirely in Django, we decided to integrate CKEditor using the django-ckeditor package. CKEditor provides a huge list of out-of-the-box functionalities. Thinking from the perspective of recruiters and problem setters, we decided to opt for a few of them only. The Django CKEditor package reads the configuration from the settings.py file. Here is the snapshot of what the CKEditor configura

## Introducing Nuskha

DevFeed: [Introducing Nuskha](<https://devfeed.tech/articles/introducing-nuskha-20010.md>)

Original publisher: [Read original article](<http://engineering.hackerearth.com/2018/07/07/introducing-nuskha/>)

Published: 2018-07-07T00:00:00Z

Content type: article

Language: en

Sources: [HackerEarth](<https://devfeed.tech/sources/hackerearth.md>)

Topics: [Front end](<https://devfeed.tech/topics/frontend.md>), [Framework](<https://devfeed.tech/topics/framework.md>), [React](<https://devfeed.tech/topics/react.md>), [modern web development](<https://devfeed.tech/topics/modern-web-development.md>), [Bootstrap](<https://devfeed.tech/topics/bootstrap.md>), [Hackathon](<https://devfeed.tech/topics/hackathon.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [components](<https://devfeed.tech/tags/components.md>), [css](<https://devfeed.tech/tags/css.md>), [developer](<https://devfeed.tech/tags/developer.md>), [development](<https://devfeed.tech/tags/development.md>), [framework](<https://devfeed.tech/tags/framework.md>), [frontend](<https://devfeed.tech/tags/frontend.md>), [hackathon](<https://devfeed.tech/tags/hackathon.md>), [react](<https://devfeed.tech/tags/react.md>), [software](<https://devfeed.tech/tags/software.md>), [web](<https://devfeed.tech/tags/web.md>)

### AI overview

HackerEarth introduces Nuskha, an internal front-end framework created to provide reusable CSS classes and components for web interfaces. The article describes its evolution from an initial shared stylesheet into a framework intended to unify components across React projects, improve consistency and ease of use, speed development, and reduce duplicated code.

### Source excerpt

History We at HackerEarth created a single-page document with common and special CSS classes to make layouts, grids, buttons, inputs, tables, tooltips, and form elements in late 2017. That was our first attempt to develop on our own front-end framework. Old Nuskha screens: Framework is a platform, foundation on which ready software solutions are built, in this particular case - web interfaces. For this purpose front-end framework consists of ready components, which are used by a developer when working on a project. What is more, aforementioned components, if necessary, can be modified or adjusted to current needs. - Merix Studio Our development was inspired from Bootstrap. But, we still had miles to go before calling it a framework. To be a part of something that will impact the whole organization was exciting for the bunch of us. After rejecting Kriya Kalaap, Kalakari, Retro, Tattva, Lipstick, and many more, we named our nascent framework Nuskha. "The name 'Nuskha' is inspired by one of the art deities "Nuska" from the Mesopotamian mythology. The word 'Nuskha' is a Hindi word which translates to 'formula' in English - a formula to create or build something." Old Nuskha helped but was still inefficient. We did not have any React components. We had started developing one of our products in React (version 16+) while the other product was in the transitioning phase. With strict deadlines for other important tasks, we were unable to contribute much to Nuskha and inevitably the implementation of the same components in different projects was duplicated. We needed a better framework to unify the components. We needed it for consistency, ease of use, and faster development. Yes, we also wanted to DRY up our code base. Fast forward to few months, as the tradition at HackerEarth goes, we had our internal hackathon scheduled. The timing was perfect. I paired up with Akanksha, another Frontend Engineer at HackerEarth, this time to build Nuskha 2.0 which will eventually be known

## Streaming Android applications via the browser

DevFeed: [Streaming Android applications via the browser](<https://devfeed.tech/articles/streaming-android-applications-via-the-browser-20009.md>)

Original publisher: [Read original article](<http://engineering.hackerearth.com/2017/04/03/streaming-android-apps-via-the-browser/>)

Published: 2017-04-03T00:00:00Z

Content type: article

Language: en

Sources: [HackerEarth](<https://devfeed.tech/sources/hackerearth.md>)

Topics: [Android](<https://devfeed.tech/topics/android.md>), [APK](<https://devfeed.tech/topics/apk.md>), [Streaming](<https://devfeed.tech/topics/streaming.md>), [Emulator](<https://devfeed.tech/topics/emulator.md>), [browser](<https://devfeed.tech/topics/browser.md>), [Front end](<https://devfeed.tech/topics/frontend.md>), [Programming](<https://devfeed.tech/topics/programming.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [apk](<https://devfeed.tech/tags/apk.md>), [applications](<https://devfeed.tech/tags/applications.md>), [benchmarks](<https://devfeed.tech/tags/benchmarks.md>), [browser](<https://devfeed.tech/tags/browser.md>), [bugs](<https://devfeed.tech/tags/bugs.md>), [emulator](<https://devfeed.tech/tags/emulator.md>), [integration](<https://devfeed.tech/tags/integration.md>), [performance](<https://devfeed.tech/tags/performance.md>), [programming](<https://devfeed.tech/tags/programming.md>), [streaming](<https://devfeed.tech/tags/streaming.md>), [user-experience](<https://devfeed.tech/tags/user-experience.md>)

### AI overview

This HackerEarth engineering article describes the difficulties of evaluating Android APK submissions manually during hiring challenges. Recruiters had to download and install each APK on a connected Android device or emulator, interact with the application, and record scores for compliance, bugs, performance, appearance, and user experience. The article introduces objectives for a browser-based system that provisions emulators, streams application interaction through the browser, automates emulator operations, and integrates with the recruiter dashboard.

### Source excerpt

HackerEarth prides itself in its scalable & automated evaluation system. What was initially designed keeping standard programming problems in mind (check this post out), gradually evolved to accommodate a plethora of problem types across various tech domains. Currently supported Problem Types Programming Frontend Objective Android Subjective File based Multiplayer Approximate Golf Machine Learning SQL Regex File eval Map Reduce Note: Not all of the problem types are accessible by end users publicly. Some are reserved for HackerEarth's Recruit product. While most of them have their own evaluation stack and are automated in the complete sense of the word, evaluating submissions for some of these problem types requires partial manual intervention. Evaluation of Android submissions for instance, is not automated. Why though? An android submission is basically an apk. Given a requirement, the user has the freedom of designing and implementing an app in whatever way he/she deems fit. Given the nature of such submissions, it would be ill conceived to design an evaluation system in a one-size-fits-all manner. Hence the need for manual intervention. Evaluating Android Submissions Each submission is rated based on the following parameters: Requirement compliance Bugs Performance benchmarks Look and feel of the application User experience For a given hiring challenge, a dashboard containing all the submissions along with the candidate details is provided to the recruiter. The recruiter then follows each of these steps: Download a candidate's apk onto his/her local machine Install the apk onto a connected android device or emulator Test and interact with the app on a device or emulator Update score for the candidate in the dashboard Straight off, you can identify serious cons to this approach. Android Studio should be set up on your local machine(for a non-technical guy, this can be a daunting task in itself) Manually install & uninstall apps from an emulator/device Error-prone

## Monitoring and alert system using Graphite and Cabot

DevFeed: [Monitoring and alert system using Graphite and Cabot](<https://devfeed.tech/articles/monitoring-and-alert-system-using-graphite-and-cabot-20008.md>)

Original publisher: [Read original article](<http://engineering.hackerearth.com/2017/03/21/monitoring-and-alert-system-using-graphite-and-cabot/>)

Published: 2017-03-21T00:00:00Z

Content type: article

Language: en

Sources: [HackerEarth](<https://devfeed.tech/sources/hackerearth.md>)

Topics: [Monitoring](<https://devfeed.tech/topics/monitoring.md>), [site-reliability-engineering](<https://devfeed.tech/topics/site-reliability-engineering.md>), [telemetry](<https://devfeed.tech/topics/telemetry.md>), [dashboards](<https://devfeed.tech/topics/dashboards.md>), [Amazon Web Services](<https://devfeed.tech/topics/aws.md>), [backends](<https://devfeed.tech/topics/backends.md>)

Tags: [apis](<https://devfeed.tech/tags/apis.md>), [aws](<https://devfeed.tech/tags/aws.md>), [backend](<https://devfeed.tech/tags/backend.md>), [dashboards](<https://devfeed.tech/tags/dashboards.md>), [infrastructure](<https://devfeed.tech/tags/infrastructure.md>), [metrics](<https://devfeed.tech/tags/metrics.md>), [monitoring](<https://devfeed.tech/tags/monitoring.md>), [on-call](<https://devfeed.tech/tags/on-call.md>), [visualization](<https://devfeed.tech/tags/visualization.md>)

### AI overview

This article describes a monitoring and alerting system for complex product infrastructure. It covers collecting, forwarding, storing, visualizing, and querying time-series metrics, along with monitoring checks, dashboards, and alerts for service owners and on-call teams. It also explains the motivation for replacing ad hoc monitoring scripts and AWS CloudWatch email alarms.

### Source excerpt

Introduction The infrastructure that powers a product and all of the services that it provides can be huge and complex because the product is scaled to serve millions of users. In most cases, each service might depend on various components for seamless functioning. With a product that houses a variety of features with critical infrastructure components and services powering these features, it becomes vital to monitor these components and services and keep them running at any cost. This monitoring system has to handle the following: Gathering data from all the components and services Storing the data efficiently and in an easily accessible manner Visualizing the data for faster comprehension Making sense of this data and relaying alerts to the respective owners of the services and components Managing the on call team and alerting them immediately At HackerEarth... Initially when we began facing problems because of some of our machines and services going down, we wrote ad hoc monitoring scripts that ran as crons to send email alerts. We also set up AWS Cloudwatch alarms to send notifications via email. There came a time when we had a very high number of components to be monitored and we realised that we were not getting enough insight into the load and usage of our machines. This is when we decided to put a system in place to collect data from these monitors and services. We also added a monitoring component to send alerts in more reliable ways (through phone calls) to the product owners and our on-call team, in case of any downtime. Components of this system This system consists of the following components that work together, Collection: Tool for collecting metrics from all the infrastructure components Forwarding: Tool for aggregating the metrics that are recieved from various machines and services and routing it to different storage backends Visualization: Tool for generating graphs and visualizing metrics APIs: Backend that provides APIs to query the metrics data fo

## Leveraging ReactJS in HackerEarth Assessment Environment

DevFeed: [Leveraging ReactJS in HackerEarth Assessment Environment](<https://devfeed.tech/articles/leveraging-reactjs-in-hackerearth-assessment-environment-20007.md>)

Original publisher: [Read original article](<http://engineering.hackerearth.com/2017/03/07/leveraging-reactjs-in-hackerearth-assessment-environment/>)

Published: 2017-03-07T00:00:00Z

Content type: article

Language: en

Sources: [HackerEarth](<https://devfeed.tech/sources/hackerearth.md>)

Topics: [reactive](<https://devfeed.tech/topics/reactive.md>), [ui](<https://devfeed.tech/topics/ui.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [HTML](<https://devfeed.tech/topics/html.md>), [HTTP](<https://devfeed.tech/topics/http.md>), [Ajax](<https://devfeed.tech/topics/ajax.md>), [Code](<https://devfeed.tech/topics/code.md>), [modern web development](<https://devfeed.tech/topics/modern-web-development.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [components](<https://devfeed.tech/tags/components.md>), [html](<https://devfeed.tech/tags/html.md>), [http](<https://devfeed.tech/tags/http.md>), [make](<https://devfeed.tech/tags/make.md>), [programming](<https://devfeed.tech/tags/programming.md>), [reactive](<https://devfeed.tech/tags/reactive.md>), [render](<https://devfeed.tech/tags/render.md>), [ui](<https://devfeed.tech/tags/ui.md>)

### AI overview

This article explains how HackerEarth uses ReactJS to build a reactive programming assessment interface. It describes the existing architecture, including question navigation, HTTP and Ajax requests, server-rendered HTML, a code editor, and recording coding sessions as replayable frames. The supplied text ends while introducing implementation pain points.

### Source excerpt

ReactJS, as the name suggests, helps create reactive (read interactive) UIs. If we have a UI with many interactive elements and on each interaction a bunch of elements change, ReactJS efficiently updates and renders the required elements. At HackerEarth, one such UI is the programming assessment environment. Programming assessment environment is one of the most critical products of HackerEarth. The mockup below is a broad idea of what it is composed of. The system in place Let's briefly understand the components in the mockup above. There are three major components: The left pane This is the primary navigational part of the interface. This controls which question is visible in the right pane. It enables candidates to switch between questions as per their convenience. The upper right pane This contains the detailed description of the question which is selected in the left pane. The lower right pane This is a medium for the candidate to submit answer to the question above. As of now, we are assuming that we have a programming question. So let's have a Code Editor here. Now, let's take a look at how things work in the current architecture. In the first HTTP response, we render all the questions in the left pane. There's no html in right pane. On selecting a question in left pane, an ajax call is made to fetch the data. The call returns a pre-rendered html of the entire question description, and it provides the candidate with a way to make further ajax calls to load the code editor. We won't get into the details of each part of the question description, however, for now, let's assume that it is composed of many smaller components. When the candidate is ready to attempt the question, another ajax call is made to render the code editor. We have extended ace editor and written a wrapper over it to fit in our requirements. One such requirement is to record every keystroke and create a frame for it. Later, we can play all those frames and see the entire code editing session

## WTF is MVP ?

DevFeed: [WTF is MVP ?](<https://devfeed.tech/articles/wtf-is-mvp-20006.md>)

Original publisher: [Read original article](<http://engineering.hackerearth.com/2016/11/17/wtf-is-mvp/>)

Published: 2016-11-17T00:00:00Z

Content type: tutorial

Language: en

Sources: [HackerEarth](<https://devfeed.tech/sources/hackerearth.md>)

Topics: [Android](<https://devfeed.tech/topics/android.md>), [App](<https://devfeed.tech/topics/app.md>), [ui](<https://devfeed.tech/topics/ui.md>), [Testing](<https://devfeed.tech/topics/testing.md>), [Automation](<https://devfeed.tech/topics/automation.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [app](<https://devfeed.tech/tags/app.md>), [architecture](<https://devfeed.tech/tags/architecture.md>), [automation](<https://devfeed.tech/tags/automation.md>), [testing](<https://devfeed.tech/tags/testing.md>), [tests](<https://devfeed.tech/tags/tests.md>), [ui](<https://devfeed.tech/tags/ui.md>)

### AI overview

This article explains Model-View-Presenter (MVP) architecture for software engineers developing apps, especially Android apps. It describes how the Model, View, and Presenter separate responsibilities, improve maintainability and readability, and support rigorous testing. It also introduces layer contracts and discusses using fragments for tablet layouts.

### Source excerpt

If you are here searching for answers about Minimum Viable Product or you are here as a result of watching the first episode of the first season of Silicon Valley, this might not be the blog you are looking for. If you are a software engineer and you develop apps (especially on Android), this is a must read. Either way, you can share this blog among other software developers you know! :) Model-View-Presenter MVP stands for Model, View, Presenter. MVP is a way to abstract or decouple different components to make them independent of each other. This makes the codebase cleaner, improves readability, improves maintainability and also helps in rigorous testing. Model : Data access layer such as database API or remote server API. View : Layer that shows/displays data and reacts to user actions. This could be an Activity, Fragment, View or Dialog. This contains almost no logic. Converts presenters commands to UI actions and listens to user actions which are passed to the presenter. Presenter : Layer that provides View with the data from Model. Presenters essentially sits in between Models and Views. Why do we need MVP ? KISS : Stands for Keep It Simple, Stupid or Keep It Stupid Simple. Don't fight with the Views. Fight with business logic. Decouple : Helps in concentrating on the problem. Helps solving issues like configuration changes, background tasks, etc Most problems will be handled by the architecture itself and the app wouldn't need external libraries to handle specific issues. Rigorous testing : Helps in building testable apps by writing automation tests. How do we develop apps for the next billion users ? We start defining contracts for each layer. A contract is a class or an agreement. We define contracts for all the layers in the architecture - Model, View and Presenter. Let's take an example of showing the latest challenges on HackerEarth to users. ChallengesContract.java class defines two interfaces, one each for the View and the Presenter. The view specific f

## Sending emails to our half million and growing user community

DevFeed: [Sending emails to our half million and growing user community](<https://devfeed.tech/articles/sending-emails-to-our-half-million-and-growing-user-community-20005.md>)

Original publisher: [Read original article](<http://engineering.hackerearth.com/2016/02/11/sending-emails-to-our-half-million-and-growing-user-community/>)

Published: 2016-02-11T00:00:00Z

Content type: article

Language: en

Sources: [HackerEarth](<https://devfeed.tech/sources/hackerearth.md>)

Topics: [API](<https://devfeed.tech/topics/api.md>), [MongoDB](<https://devfeed.tech/topics/mongodb.md>), [MySQL](<https://devfeed.tech/topics/mysql.md>), [Django](<https://devfeed.tech/topics/django.md>), [HTML](<https://devfeed.tech/topics/html.md>), [html elements](<https://devfeed.tech/topics/html-elements.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [architecture](<https://devfeed.tech/tags/architecture.md>), [asynchronous-architecture](<https://devfeed.tech/tags/asynchronous-architecture.md>), [database](<https://devfeed.tech/tags/database.md>), [infrastructure-monitoring](<https://devfeed.tech/tags/infrastructure-monitoring.md>), [mongodb](<https://devfeed.tech/tags/mongodb.md>), [mysql](<https://devfeed.tech/tags/mysql.md>), [queue](<https://devfeed.tech/tags/queue.md>), [rabbitmq](<https://devfeed.tech/tags/rabbitmq.md>), [sendgrid](<https://devfeed.tech/tags/sendgrid.md>)

### AI overview

HackerEarth describes an asynchronous email delivery architecture for sending large volumes of user notifications. Emails are serialized and stored, metadata is placed in RabbitMQ queues, and workers reconstruct and deliver messages through SendGrid, with priority queues used to reduce waiting time.

### Source excerpt

At hackerearth we send emails to keep our users updated on upcoming challenges and their activities, for example, when a user successfully solves a problem, receives test-invitation, updates on user comments. Basically whenever it is appropriate. Architecture It takes lot of computational power to send emails in such large quantities synchronously. So we have implemented an asynchronous architecture to send emails. Here is brief overview of the architecture: Step 1: Construct an email and save the serialized email object in database. Step 2: Queue the metadata for later consumption. Step 3: Consume the metadata, recreate the email object and deliver. The diagram below shows high level architecture of emailing system. The solid line represents the data flow between different components. The dotted line represents the communications. Hackerearth email infrastructure consists of MySQL database, MongoDB database, RabbitMQ queues. Journey Of Email Step 1 - Construct email: There are two different type of emails. Text - Plain text emails Html - Emails with rich interface using html elements. These emails are made using django templates API used by hackerearth developers for sending email - send_email(ctx, template, subject, from_email, html=False, async=True, **kwargs) The above API creates Sendgrid Mail object, serializes and saves it in the db with some additional data. A piece of code similar to the bit shown below is used to create sendgrid Mail object import sendgrid sg = sendgrid.SendGridClient('YOUR_SENDGRID_API_KEY') message = sendgrid.Mail() message.add_to('John Doe <john@email.com>') message.set_subject('Example') message.set_html('Body') message.set_text('Body') message.set_from('Doe John <doe@email.com>') status, msg = sg.send(message) Model below is used for storing the serialized mail object and additional data. class Message(): # The actual data - a pickled sendgrid.Mail object message_data = models.TextField() when_added = models.DateTimeField(default=date

## Analyzing submissions in real time for social media updates

DevFeed: [Analyzing submissions in real time for social media updates](<https://devfeed.tech/articles/analyzing-submissions-in-real-time-for-social-media-updates-20003.md>)

Original publisher: [Read original article](<http://engineering.hackerearth.com/2016/02/02/analyzing-submissions-realtime-for-social-media-updates/>)

Published: 2016-02-02T00:00:00Z

Content type: article

Language: en

Sources: [HackerEarth](<https://devfeed.tech/sources/hackerearth.md>)

Topics: [real-time](<https://devfeed.tech/topics/real-time.md>), [Redis](<https://devfeed.tech/topics/redis.md>), [Kafka](<https://devfeed.tech/topics/kafka.md>), [Database](<https://devfeed.tech/topics/database.md>), [App](<https://devfeed.tech/topics/app.md>), [Persistence](<https://devfeed.tech/topics/persistence.md>), [payload](<https://devfeed.tech/topics/payload.md>), [data](<https://devfeed.tech/topics/data.md>), [coding](<https://devfeed.tech/topics/coding.md>)

Tags: [app](<https://devfeed.tech/tags/app.md>), [coding](<https://devfeed.tech/tags/coding.md>), [contests](<https://devfeed.tech/tags/contests.md>), [data](<https://devfeed.tech/tags/data.md>), [database](<https://devfeed.tech/tags/database.md>), [kafka](<https://devfeed.tech/tags/kafka.md>), [leaderboard](<https://devfeed.tech/tags/leaderboard.md>), [marketing](<https://devfeed.tech/tags/marketing.md>), [payload](<https://devfeed.tech/tags/payload.md>), [persistence](<https://devfeed.tech/tags/persistence.md>), [posts](<https://devfeed.tech/tags/posts.md>), [real-time](<https://devfeed.tech/tags/real-time.md>), [redis](<https://devfeed.tech/tags/redis.md>), [server](<https://devfeed.tech/tags/server.md>), [social-media](<https://devfeed.tech/tags/social-media.md>)

### AI overview

This article explains how HackerEarth built a real-time social media update system for coding and hiring challenges. It uses Redis to maintain submission counters and state, Kafka to deliver submission payloads to an asynchronous worker, database queries at selected thresholds, and scheduled or delayed posting to avoid duplicate tweets and excessive update frequency.

### Source excerpt

Objective In Jan 2015, HackerEarth conducted nearly 10-12 hiring challenges, 5-6 coding challenges and numerous college challenges. HackerEarth has a decent social media presence and we wanted to inform our followers about the events at HackerEarth. One of the main objectives of this project was to provide flexibility to the marketing team to automate simple jobs and to focus on sophisticated campaigns. Design Goals As a first step, we decided to post about our events and their highlights on twitter. We covered event reminders, start/end of contests, who scored first AC and leaderboard updates at the end of a contest. We chose to do it by reading from the biggest and the meanest table of our database of Submissions. Challenges The submissions table is a very large table. An additional query on the submissions table during peak hours was not favourable. Hence, we did not count the submissions in-place and instead queued them to be processed later. Preventing duplicate tweets while maintaining state is also a challenge. Solution The application made a high volume of reads, few writes/updates. So any key/value stored would do the job. We chose Redis in lieu of Memcached. Redis offers data persistence in the event of node failure. This is very useful to avoid duplicate tweets. For instance, Two different users being credited for first AC submission in an event. By setting key expiry time and less number of keys for a single event, we prevented our Redis server from being overloaded. We maintained a key in Redis to keep count of submissions for an event. Reading from the database was not recommended because it would make a read call per submission during peak time and Redis performed faster reads. The application is an asynchronous worker and payload containing submission_id and event_id are passed to it using Kafka. So when the Redis key counter hit the magic numbers (1, 100, 500, multiples of 1000), The worker makes a DB query and posts a tweet. Worker subscribes to a

## Beautiful Math Symbols

DevFeed: [Beautiful Math Symbols](<https://devfeed.tech/articles/beautiful-math-symbols-20004.md>)

Original publisher: [Read original article](<http://engineering.hackerearth.com/2016/02/02/latex-support-using-MathJax/>)

Published: 2016-02-02T00:00:00Z

Content type: article

Language: en

Sources: [HackerEarth](<https://devfeed.tech/sources/hackerearth.md>)

Topics: [math](<https://devfeed.tech/topics/math.md>), [Library](<https://devfeed.tech/topics/library.md>), [Markdown](<https://devfeed.tech/topics/markdown.md>), [Ajax](<https://devfeed.tech/topics/ajax.md>), [browser](<https://devfeed.tech/topics/browser.md>), [Code](<https://devfeed.tech/topics/code.md>), [Programming](<https://devfeed.tech/topics/programming.md>)

Tags: [article](<https://devfeed.tech/tags/article.md>), [browser](<https://devfeed.tech/tags/browser.md>), [code](<https://devfeed.tech/tags/code.md>), [library](<https://devfeed.tech/tags/library.md>), [markdown](<https://devfeed.tech/tags/markdown.md>), [math](<https://devfeed.tech/tags/math.md>), [programming](<https://devfeed.tech/tags/programming.md>)

### AI overview

The article explains how HackerEarth added LaTeX rendering with MathJax for mathematical symbols in programming-puzzle content. It describes handling editor previews, synchronous page content, and dynamically loaded Ajax content, using Markdown processing hooks and MathJax's asynchronous queue.

### Source excerpt

Introduction: By nature HackerEarth has so many programming puzzles. These puzzles bound to have mathematical equations, statements and symbols. Problem Setters often requested us to add support for Latex. Implementation: The obvious and easy solution for this is to implement Latex support for individual pages. But that's not scalable and maintainable. Then we came with up with a solution where we didn't have to write custom code for every page. We examined the site and figured out three type of rendering that happens in the browser. Before going to solutions case by case, let's first understand how MathJax, the library we use for typesetting Latex, works. Everything in MathJax works asynchronously. After initializing MathJax, it executes a set of tasks and then typesets the queued content. Everything in MathJax works asynchronously using queues. Mathjax docs explains it in detail. Types of rendering: Rendering of preview section in editor Static content rendering (synchronous) Rendering of dynamic content via Ajax (Asynchronous) Read through rest of the article for this categorization to make sense. Editor: We use pagedown editor throughout our site. It has a preview section which displays the converted markdown content. Now this should also display typesetted Latex content. Pagedown editor has feature called hooks. This is a mechanism for plugging external text processors in between various steps of markdown processing. We have written a hook for typesetting Latex macros. This is chained to the hooks at the end, after all the markdown processing is completed. This hook takes markdown processed content as input and spits out Latex typesetted content. function renderLatex(text) { var invisible_div = document.createElement("div"); invisible_div.style.cssText = "display:hidden"; attr = document.createAttribute("id"); attr.value = "mathjax_text"; invisible_div.setAttributeNode(attr); invisible_div.innerHTML = text; document.body.appendChild(invisible_div); elem = docum

## Profiling django views for SQL queries

DevFeed: [Profiling django views for SQL queries](<https://devfeed.tech/articles/profiling-django-views-for-sql-queries-20002.md>)

Original publisher: [Read original article](<http://engineering.hackerearth.com/2016/02/01/profiling-django-views/>)

Published: 2016-02-01T00:00:00Z

Content type: article

Language: en

Sources: [HackerEarth](<https://devfeed.tech/sources/hackerearth.md>)

Topics: [Django](<https://devfeed.tech/topics/django.md>), [SQL](<https://devfeed.tech/topics/sql.md>), [Python](<https://devfeed.tech/topics/python.md>), [Code](<https://devfeed.tech/topics/code.md>), [Hackathon](<https://devfeed.tech/topics/hackathon.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [django](<https://devfeed.tech/tags/django.md>), [hackathon](<https://devfeed.tech/tags/hackathon.md>), [profiling](<https://devfeed.tech/tags/profiling.md>), [python](<https://devfeed.tech/tags/python.md>), [sql](<https://devfeed.tech/tags/sql.md>)

### AI overview

The article describes a profiler for Django views that identifies the exact code expressions causing SQL queries. It uses Python AST manipulation to instrument function calls and attribute access, while tracking queries generated during execution.

### Source excerpt

We at HackerEarth regularly conduct 24-hours internal hackathons usually once a month to boost ourselves to get familiar with new technologies and to come up with great ideas and hacks to increase our productivity. A hackathon project can be anything from creating a new product to creating some tools which helps our own devlopment. In the hakathon in Dec 2015, I came up with the idea to create a profiler which could tell which code inside django views causes SQL queries so that we can optimize them easily. Initial thoughts There are already many good django packages to profile views for SQL queries. One of them is django-toolbar which we already use. Django-toolbar is great but it shows all raw SQL queries which are happening inside a view and you have to analyze each query, see the whole traceback and figure out which line of code inside the view is triggering the query. This way, you can only figure out the line number of the code in a file, not the exact function or expression or attribute access which is causing the query. What I wanted was that a profiler should tell about the exact expressions which trigger the SQL queries. There were some solutions which came up in my mind to get it done like using tracebacks or by manipulating AST of the python function. Praveen had just told me about the python's ast module which can parse and modify code during runtime and I was fascinated about using it in future. I chose to use AST manipulation to implement the profiler and the trick here is to patch every function call, attribute access and other constructs. Here is what I thought: Suppose there is a function f which internally calls get_user triggering a SQL query @profile def f(request): ... user = get_user(request) ... and decorating the function f with profile decorator will manipulate its AST code. It will find all locations of function calls inside function body and will encapsulate it in our special function call_handler. So the function f's definition will becom

## Smart suggestions with Django, Elasticsearch and Haystack

DevFeed: [Smart suggestions with Django, Elasticsearch and Haystack](<https://devfeed.tech/articles/smart-suggestions-with-django-elasticsearch-and-haystack-20001.md>)

Original publisher: [Read original article](<http://engineering.hackerearth.com/2016/01/29/smart-sugesstions-with-elasticsearch/>)

Published: 2016-01-29T00:00:00Z

Content type: tutorial

Language: en

Sources: [HackerEarth](<https://devfeed.tech/sources/hackerearth.md>)

Topics: [elasticsearch](<https://devfeed.tech/topics/elasticsearch.md>), [Django](<https://devfeed.tech/topics/django.md>), [data](<https://devfeed.tech/topics/data.md>), [Latency](<https://devfeed.tech/topics/latency.md>), [tokenizers](<https://devfeed.tech/topics/tokenizers.md>), [servers](<https://devfeed.tech/topics/servers.md>)

Tags: [data](<https://devfeed.tech/tags/data.md>), [django](<https://devfeed.tech/tags/django.md>), [elasticsearch](<https://devfeed.tech/tags/elasticsearch.md>), [latency](<https://devfeed.tech/tags/latency.md>), [mapping](<https://devfeed.tech/tags/mapping.md>), [search](<https://devfeed.tech/tags/search.md>), [tokenizers](<https://devfeed.tech/tags/tokenizers.md>)

### AI overview

This tutorial explains how HackerEarth uses Django, Elasticsearch, and Haystack to provide smart suggestions over large collections of user data. It introduces inverted indexes, discusses the trade-off between search relevance and latency, and describes how Elasticsearch analyzers, tokenizers, token filters, character filters, and field mappings can be configured for effective search.

### Source excerpt

Introduction One of the primary issues when gathering information from users is suggesting the right options that they are looking for. At HackerEarth, we gather information from all our developers which help us provide them a better experience. So there came a time when we had to suggest very smartly to our users! :D When humongous amounts of data has to be indexed and suggested intelligently, one of the efficient ways to do it is by using an inverted index. An inverted index basically is a map of words that appear in documents to a list of documents the word is found in. Popular Lucene based search servers like Elasticsearch and Solr are tools to maintain large inverted indexes and provide an efficient means to look up documents. Here is an example from the profiles page on HackerEarth. We use Elasticsearch to index millions of documents with various fields. Two hurdles to be crossed while solving this problem are latency and relevance. Relevent documents have to be suggested to the user while keeping the time taken to retrieve them (ie. latency) as low as possible. Elasticsearch uses analyzers that help in achieving good relevence, but only if used in a witty manner. It also allows us to build our own custom analyzers. So by assaying the user input, astute analyzers can be built to increase relevance. A simple example for a document can be something like, { '_id' : 'AVJUN6QaLYvICHZxvYEq', 'username': 'ksrvtsa', 'location': 'Bangalore', 'hobbies': ['music', 'reading', 'hiking'], } So what are analyzers? An analyzer converts the text to be indexed and creates lookups for finding the text when needed using appropriate search terms. An analyzer is composed of a tokenizer that splits your text into multiple tokens which is followed by many token filters which modify, delete or add new tokens. The tokenizer can be preceded by character filters which modify the text before passing it to the tokenizer. Every field in a document has an index analyzer and a search analyzer

## A/B testing using Django

DevFeed: [A/B testing using Django](<https://devfeed.tech/articles/a-b-testing-using-django-19998.md>)

Original publisher: [Read original article](<http://engineering.hackerearth.com/2016/01/29/ab-testing-using-django/>)

Published: 2016-01-29T00:00:00Z

Content type: tutorial

Language: en

Sources: [HackerEarth](<https://devfeed.tech/sources/hackerearth.md>)

Topics: [A/B Testing](<https://devfeed.tech/topics/a-b-testing.md>), [Django](<https://devfeed.tech/topics/django.md>), [Testing](<https://devfeed.tech/topics/testing.md>), [Framework](<https://devfeed.tech/topics/framework.md>), [Web](<https://devfeed.tech/topics/web.md>)

Tags: [a-b-testing](<https://devfeed.tech/tags/a-b-testing.md>), [analytics](<https://devfeed.tech/tags/analytics.md>), [code](<https://devfeed.tech/tags/code.md>), [django](<https://devfeed.tech/tags/django.md>), [framework](<https://devfeed.tech/tags/framework.md>), [testing](<https://devfeed.tech/tags/testing.md>), [web](<https://devfeed.tech/tags/web.md>)

### AI overview

This article explains how HackerEarth built a custom A/B testing framework in Django after existing third-party libraries did not meet its needs. It covers assigning users to buckets, routing users to different views or templates, supporting anonymous users, keeping assignments sticky, and tracking analytics.

### Source excerpt

Whenever we roll out an improvement on our platform, we at HackerEarth love to conduct A/B tests on the improvement to understand which iteration helps our users more in using the platform in a better way. Since the available third party libraries did not quite meet our needs, we wrote our own A/B testing framework in Django. In this post we will share a few insights as to how we accomplished this. The basics A lot of products, especially on web, use a method called A/B testing or split testing to quantify how well a new page or layout performs as compared to the old one. The crux of the method is to show layout 'A' to a certain set or bucket of users and layout 'B' to another set of users. The next step is to track user actions leading to certain milestones, which would provide critical data regarding the 'effectiveness' of both the pages or layouts. Before we began writing code for the framework, we made a list of all the things that we wanted the framework to do - Route users to multiple views (with different templates) Route users to a single view with different templates Make the views/templates stick for users A/B test visitors who do not have an account on HackerEarth (anonymous users) Sticky views/templates for anonymous users as well Support for A/A/B or A/B/C/D..../n/ testing (just for the heck of it!) Analytics We went out to grab some pizza and beer, and when we got back we came up with this wire-frame - A/B for Views A/B for Templates Getting the logic right To begin with, we had to categorize our users into buckets. So all our users were assigned a bucket number ranging from 1 to 120. This numbering is not strict and the range can be arbitrary or as per your needs. Next, we defined two constants - the first one specifies which view a user is routed to, and the second one specifies the fallback or primary view. The tuples in the first constant are the bucket numbers assigned to users. The primary view in the second constant will be used when we do not wan

## Managing roles and access control in a web application

DevFeed: [Managing roles and access control in a web application](<https://devfeed.tech/articles/managing-roles-and-access-control-in-a-web-application-20000.md>)

Original publisher: [Read original article](<http://engineering.hackerearth.com/2016/01/29/managing-roles-and-access-control/>)

Published: 2016-01-29T00:00:00Z

Content type: article

Language: en

Sources: [HackerEarth](<https://devfeed.tech/sources/hackerearth.md>)

Topics: [Access Control](<https://devfeed.tech/topics/access-control.md>), [Authorization](<https://devfeed.tech/topics/authorization.md>), [web applications](<https://devfeed.tech/topics/web-applications.md>), [Django](<https://devfeed.tech/topics/django.md>), [Python](<https://devfeed.tech/topics/python.md>), [Code](<https://devfeed.tech/topics/code.md>), [Filesystems](<https://devfeed.tech/topics/filesystems.md>), [Networks](<https://devfeed.tech/topics/networks.md>)

Tags: [access-control](<https://devfeed.tech/tags/access-control.md>), [applications](<https://devfeed.tech/tags/applications.md>), [code](<https://devfeed.tech/tags/code.md>), [django](<https://devfeed.tech/tags/django.md>), [files](<https://devfeed.tech/tags/files.md>), [filesystem](<https://devfeed.tech/tags/filesystem.md>), [networking](<https://devfeed.tech/tags/networking.md>), [networks](<https://devfeed.tech/tags/networks.md>), [processes](<https://devfeed.tech/tags/processes.md>), [python](<https://devfeed.tech/tags/python.md>), [web](<https://devfeed.tech/tags/web.md>)

### AI overview

This article explains how HackerEarth Recruit implements role-based access control for administrators in a Django application. It introduces access control lists (ACLs), maps roles and privileges to application features, and uses decorators to restrict view access.

### Source excerpt

HackerEarth Recruit, is a platform for technical recruitment. Many companies use this platform for candidate assessments and interviewing. There can be multiple admins for a company account. As teams grow in size, access control is a special concern for applications that deal with financial and privacy data. Access control is concerned with determining the allowed activities of legitimate users, but we required more sophisticated and complex control mediating every attempt by a user to access a resource in the application based on the sensitivity level of various features. A state of access control is said to be safe if no permission can be leaked to an unauthorized or uninvited principal. We figured that the simpliest solution to restrict access was to use ACL. What is ACL ? An access control list (ACL), with respect to a computer file system, is a list of permissions attached to an object. An ACL specifies which users or system processes are granted access to objects, as well as what operations are allowed on given objects. Many kinds of systems implement ACL, or have a historical implementation like Filesystem ACLs and Networking ACLs. A filesystem ACL is a data structure (usually a table) containing entries that specify individual user or group rights to specific system objects such as programs, processes, or files. In Networking ACL refers to rules that are applied to port numbers or IP addresses that are available on a host or other layer 3, each with a list of hosts and/or networks permitted to use the service. For Recruit, the approach had to be role based access restriction to authorized admins. This implementation of access control mechanism is defined around roles and privileges. Implementation (Python/Django) Access control Lists can be configured to map roles to features. In this ACL implementation, roles are named after existing features which require access control. Each access right should have a unique name, and also assign a unique value to each. T

## Logging Javascript errors in production

DevFeed: [Logging Javascript errors in production](<https://devfeed.tech/articles/logging-javascript-errors-in-production-19999.md>)

Original publisher: [Read original article](<http://engineering.hackerearth.com/2016/01/29/hackerearth-logging-javascript-errors-production/>)

Published: 2016-01-29T00:00:00Z

Content type: tutorial

Language: en

Sources: [HackerEarth](<https://devfeed.tech/sources/hackerearth.md>)

Topics: [error tracking](<https://devfeed.tech/topics/error-tracking.md>), [Cross-origin resource sharing (CORS)](<https://devfeed.tech/topics/cors.md>), [Amazon S3](<https://devfeed.tech/topics/amazon-s3.md>), [JavaScript](<https://devfeed.tech/topics/javascript.md>), [Amazon Web Services](<https://devfeed.tech/topics/aws.md>), [browsers](<https://devfeed.tech/topics/browsers.md>), [Web](<https://devfeed.tech/topics/web.md>), [cURL](<https://devfeed.tech/topics/curl.md>)

Tags: [aws](<https://devfeed.tech/tags/aws.md>), [browsers](<https://devfeed.tech/tags/browsers.md>), [curl](<https://devfeed.tech/tags/curl.md>), [errors](<https://devfeed.tech/tags/errors.md>), [http](<https://devfeed.tech/tags/http.md>), [javascript](<https://devfeed.tech/tags/javascript.md>), [logging](<https://devfeed.tech/tags/logging.md>), [s3](<https://devfeed.tech/tags/s3.md>)

### AI overview

This article explains how to implement JavaScript error logging in production using errorception. It describes a CORS-related integration problem caused by serving static files from Amazon S3 through another domain, and outlines configuring S3 CORS headers so browser error details can be posted to the logging service.

### Source excerpt

We had implemented a javascript logger to capture the pesky issues our users faced and had problems when using the site. When we came up with the idea, we thought it would be just a five minute job where we would just have to add a snippet and would be done, but as it is well know, nothing is simple when it comes to real world production issues. After analyzing a lot of loggers, we decided to use errorception as our javascript logger. It was simple in its approach and it provided the data we needed. This was the easy part, next came the part of integration, and yes there was a snippet which we just had to paste in our base javascript file, but one thing we had forgotten, CORS. We host our static files on S3 and they are served via fastly, because of which they are delivered through another domain. The error tracking snippet could not log the errors because 'window.onerror' would not return the necessary stack trace and information. Many of you may have heard about CORS, it is a mechanism that allows restricted resources (e.g. fonts) on a web page to be requested from another domain outside the domain from which the resource originated. For security reasons, browsers restrict cross-origin HTTP requests initiated from within scripts. The only way to solve this and get errors to be posted to errorception was to allow CORS in the header of the static files. After some research (errorception also has a good blog on it), we finally managed to have the error logging implemented. Below are the steps we had to go through: Configuring S3 S3 has this unnecessarily complicated "CORS configuration" that you need to create. Here's the steps to get that right: Log into your AWS S3 console, select your bucket, and select "Properties". S3 CORS configurations seem to apply at the level of the bucket, and not the file. I have no clue why. Expand the "Permissions" pane, and click on "Add CORS configuration" or "Edit CORS configuration" depending on what you see. You should already be p

## HackerEarth Question Library: Stats, Usage Analysis and Health

DevFeed: [HackerEarth Question Library: Stats, Usage Analysis and Health](<https://devfeed.tech/articles/hackerearth-question-library-stats-usage-analysis-and-health-19997.md>)

Original publisher: [Read original article](<http://engineering.hackerearth.com/2015/10/31/hackerearth-question-library-data-analysis-and-health/>)

Published: 2015-10-31T00:00:00Z

Content type: article

Language: en

Sources: [HackerEarth](<https://devfeed.tech/sources/hackerearth.md>)

Topics: [Library](<https://devfeed.tech/topics/library.md>), [data](<https://devfeed.tech/topics/data.md>), [coding](<https://devfeed.tech/topics/coding.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [Data structures](<https://devfeed.tech/topics/data-structures.md>)

Tags: [coding](<https://devfeed.tech/tags/coding.md>), [data](<https://devfeed.tech/tags/data.md>), [developers](<https://devfeed.tech/tags/developers.md>), [feature](<https://devfeed.tech/tags/feature.md>), [improvements](<https://devfeed.tech/tags/improvements.md>), [library](<https://devfeed.tech/tags/library.md>), [programming](<https://devfeed.tech/tags/programming.md>), [support](<https://devfeed.tech/tags/support.md>), [technical](<https://devfeed.tech/tags/technical.md>)

### AI overview

This article describes HackerEarth's Question Library and the development of a "Health" feature that helps recruiters identify more usable assessment questions. Health is calculated from factors including question accuracy, usage frequency, and recency of use, after data analysis and storage design.

### Source excerpt

We, at HackerEarth, cater a huge number of questions in Assessment tool. Recruiters can choose from wide varieties of Multiple Choice and Programming/Coding questions to assess candidates. Every week or two, new questions are added to the Questions Library. As the time passed, thousands of questions got stacked up and recruiters started to have a hard time figuring out what questions to choose from such a huge library. We, developers, work closely with our sales team to understand recruiters' needs. Sometimes we directly get in touch with recruiters to provide on call technical support and understand how they use the product and what improvements can be made to the product in order to make it more easier to use. That's how we figured it was about time we helped recruiters figure the best questions out of our library and hence we released a feature called "Health". What it means? Health, in context of any library question, indicates how usable the question is. It is not only about question's difficulty level. We consider various factors such as number of users attempted the question, users solved, times the question has been used and when was the question last used while determining Health of any question. Simple and short, higher the health, more usable the question. How we calculate the Health value? The whole process was split into 3 parts: Data Segregation and Analysis Data Structure to store Health data Mathematical formula to calculate Health value 1. Data Segregation and Analysis We tried to gather as much data as possible for any question. Then, filter out the ones that could help us in finding the health value. Number of tests in which the question was used When was the question last used in any test Question accuracy (Number of users who solved it correctly / Number of users attempted) Problem ratings (Ratings submitted by user for any question) Problem tags When was the question added How frequently the question is used When was the question last used We f

## Logging millions of requests everyday and what it takes

DevFeed: [Logging millions of requests everyday and what it takes](<https://devfeed.tech/articles/logging-millions-of-requests-everyday-and-what-it-takes-19996.md>)

Original publisher: [Read original article](<http://engineering.hackerearth.com/2015/02/26/logging-millions-requests-what-it-takes/>)

Published: 2015-02-26T00:00:00Z

Content type: article

Language: en

Sources: [HackerEarth](<https://devfeed.tech/sources/hackerearth.md>)

Topics: [Logging](<https://devfeed.tech/topics/logging.md>), [Django](<https://devfeed.tech/topics/django.md>), [Scalability](<https://devfeed.tech/topics/scalability.md>), [Architecture & Design](<https://devfeed.tech/topics/architecture-design.md>), [log management](<https://devfeed.tech/topics/log-management.md>), [Kafka](<https://devfeed.tech/topics/kafka.md>), [Back end](<https://devfeed.tech/topics/backend.md>), [MongoDB](<https://devfeed.tech/topics/mongodb.md>)

Tags: [architecture](<https://devfeed.tech/tags/architecture.md>), [django](<https://devfeed.tech/tags/django.md>), [kafka](<https://devfeed.tech/tags/kafka.md>), [logging](<https://devfeed.tech/tags/logging.md>), [logs](<https://devfeed.tech/tags/logs.md>), [metrics](<https://devfeed.tech/tags/metrics.md>), [mongodb](<https://devfeed.tech/tags/mongodb.md>), [scalability](<https://devfeed.tech/tags/scalability.md>), [scale](<https://devfeed.tech/tags/scale.md>), [stateless](<https://devfeed.tech/tags/stateless.md>), [thread](<https://devfeed.tech/tags/thread.md>)

### AI overview

This article describes HackerEarth's architecture for collecting and processing millions of web request logs. It explains how Django middleware asynchronously forwards request data to a stateless Transporter Cluster, which routes messages to systems such as Kafka, MongoDB, and RabbitMQ while keeping web-server overhead low and supporting horizontal scaling.

### Source excerpt

HackerEarth's web servers handle millions of requests every day. These request logs can be analyzed to mine some highly useful insights as well as metrics critical for the business, for example, no. of views per day, no. of views per sub product, most popular user navigation flow etc. Initial Thoughts HackerEarth uses Django as its primary web development framework and a host of other components which have been customized for performance and scalability. During normal operations, our servers handle 80-90 requests/sec on an average and this surges to 200-250 requests/sec when multiple contests overlap in a time delta. We needed a system which could easily scale to a peak traffic 500 requests/sec. Also, this system should add minimum processing overhead to the webservers and the data collected should be stored for crunching and offline processing. Architecture The diagram above shows a high level architecture of our request log collection system. The solid connection lines represent the data flow between different components and the dotted lines represent the communications. The whole architecture is message based and stateless and so individual components can easily be removed/replaced without any downtime. Below is a more detailed explanation about each component in the order of data flow. Web Servers On the web servers, we employ a Django Middleware that asynchronously retrieves required data for a given request and then forwards it to the Transporter Cluster servers. This is done using a thread and the middleware adds an overhead of 2 milli seconds to the Django request/response cycle. class RequestLoggerMiddleware(object): """ Logs data from requests """ def process_request(self, request): if settings.LOCAL or settings.DEBUG: return None if request.is_ajax(): is_ajax = True request.META['IS_AJAX'] = is_ajax before = datetime.datetime.now() DISALLOWED_USER_AGENTS = ["ELB-HealthChecker/1.0"] http_user_agent = request.environ.get('HTTP_USER_AGENT','') if http_user_a

[Next page](<https://devfeed.tech/sources/hackerearth.md?cursor=WyIyMDE1LTAyLTI2VDAwOjAwOjAwKzAwOjAwIiwgIjcwNTczOGZiLWU4M2MtNDdhNS04Y2Y1LTZiOWJlNmIwOTk0NyJd>)