# 100,000 strong - CodeFactory server

DevFeed: [100,000 strong - CodeFactory server](<https://devfeed.tech/articles/100-000-strong-codefactory-server-19977.md>)

Original publisher: [Read original article](<http://engineering.hackerearth.com/2013/03/12/100000-strong/>)

Published: 2013-03-12T00:00:00Z

Content type: article

Language: en

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

Topics: [C](<https://devfeed.tech/topics/c.md>), [C++](<https://devfeed.tech/topics/c-plus-plus.md>), [Java](<https://devfeed.tech/topics/java.md>), [Finagle](<https://devfeed.tech/topics/finagle.md>), [Remote Procedure Call (RPC)](<https://devfeed.tech/topics/rpc.md>), [Processes](<https://devfeed.tech/topics/processes.md>), [servers](<https://devfeed.tech/topics/servers.md>), [Development](<https://devfeed.tech/topics/development.md>)

Tags: [c](<https://devfeed.tech/tags/c.md>), [c-plus-plus](<https://devfeed.tech/tags/c-plus-plus.md>), [development](<https://devfeed.tech/tags/development.md>), [distributed](<https://devfeed.tech/tags/distributed.md>), [distributed-system](<https://devfeed.tech/tags/distributed-system.md>), [ipc](<https://devfeed.tech/tags/ipc.md>), [java](<https://devfeed.tech/tags/java.md>), [process](<https://devfeed.tech/tags/process.md>), [server](<https://devfeed.tech/tags/server.md>)

## AI overview

This article recounts the development of HackerEarth's CodeFactory server. It describes an early C-based code checker that compiled and ran C, C++, and Java programs, including process execution, inter-process communication, privilege limitations, and retry handling on a shared server. The article then explains the adoption of Apache Thrift and the implementation of a client-server architecture for distributed, cross-language services, followed by expansion of the evaluation engine to languages such as Perl, PHP, Python, Ruby, and Haskell.

## Source excerpt

The Inception January 2012 was an idyllic time for us. Three of us had just teamed up to build something cool. There was no planning for the future, no sort of agreement - we were just three geeks sitting in the dorm room who wanted to build a product. We started working on MyCareerStack where there was supposed to be interview questions, tutorials etc. Soon, we realized that there was code editor needed, but that was easy. The harder part was that people don't only want to write code online, they want to run them. Now that I had never done before! What resulted then was a hacky few hundred lines of code in C, which could compile and run code in just C, C++ and Java. It might have been even the worst piece of code I had ever written, but it worked and it was sweet! /* create FIFO to be used here & later for IPC. */ char fifo_1[NAME_MAX]; createFilePath(fifo_1, id, dir, FIFO_FILE_1); umask(0); /* reset file creation mask. */ int readfd_1, writefd_1, readfd_2; if (mkfifo(fifo_1, S_IRWXU | S_IRWXG | S_IRWXO) < 0) err(1, NULL); /* Fork a child to exec the process: {id}_a.out */ pid_t pid; int status; signal(SIGALRM, handle_tle); /* change current working directory to mycareerstack */ chdir(RUNTIME_DIR); Wait, you haven't seen the ugly part yet! This will make you cringe, it made me too. See what the hell I am doing with re-tries, but it was required! int tries = 0; /* try the exec 100 times. */ while(tries < 100) { /* run the program. */ if(execl(executable, executable, (char*) 0) < 0) { // } ++tries; } printf("Couldn't run the program!"); _exit(0); There were some serious reasons for which this hack was done. We were hosted on a shared webfaction server, with no access to root. This meant I couldn't drop the user process privilege to any user with limited access permissions. I needed to create another user then with limited access which could be controlled by the original user. And again, I didn't know of any way to know if there is already a process running with privi