Giter Site home page Giter Site logo

backend-engineering-challenge's Introduction

Backend Engineering Challenge

This repository contains solution for the software problem posted in Unbabel.

I have implemented 2 scenarios for the problem statement - a spark streaming application and a python cli implementation.

SPARK Streaming

The software problem specified is a stateful streaming problem where we need to calculate aggregate data for sliding time windows. The production use case will be a directory with log files or a real time stream of message queue(probably kafka or RabbitMQ). In this application, I have used spark streaming framework to calculate aggregates. The input is a directory with 1 or more json files and output is streamed to json files in an output directory and to console for better understanding. You need scala sbt and Java. You can run the project by using java or sbt.

To run using java follow these commands from the project root folder. An uber fat jar named unbabel.jar will be generated in folder jar

sbt assembly
java -jar ./jar/unbabel.jar --input_directory input_data --window_size 10 --output_directory out

To run with sbt use this command from project root folder

sbt "run --input_directory input_data --window_size 10 --output_directory out"

Spark Streaming has restrictions reading and writing to/from a single file due its distributive nature. Also if you need to run the program again, then you may need to delete the output folder and the checkpoint-dir folder since the application will start from where it left last time. Anyways, for an ideal production scenario, the output will most probably be streamed to a kafka Queue or written to a database table. This will be ideal or those kind of scenarios.

Python Implementation

However, if specific use case as mentioned in the problem statement is required, please check out the following python implementation

python3 aggregator.py --input_file ./input_data/sample_input.json --window_size 10 --output_file out.json

In both the cases window_size provided is assumed to be in minutes

backend-engineering-challenge's People

Contributors

shinoys222 avatar bacarini avatar joaovasques avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.