Code Monkey home page Code Monkey logo

benchling-challenge's Introduction

Benchling Backend Coding Challenge:

Major Design Choices:

Thin Server: The Thin Ruby web server incorporates The Mongrel Parser, Eventmachine and Rack.

Fibers: Ruby Fibers allow you to write asynchronous code in a linear structure.

EM-Synchrony: Provides Eventmachine compatible code for many common rails applications.

EM-PostgreSQL: Provides a postgres driver that operates asynchronously.

Protobuf: Provides an efficient and standardized method of encoding data to be transferred between the device and the server. Chosen over other encoding protocols for it's support in both the Rails and Arduino environments.

How to set up:

  1. Go to the root directory and click "Register A New Device"
  2. Take note of both your device id and registration key. The device id will be how you view messages sent from the device and the registration key will be required to authenticate messages from your device.
  3. Enter that information at the top of the examples/arduino/device/device.ino arduino code

Performance

Without eventmachine, the server could not handle more than 35 concurrent requests without having to reset the connection. With eventmachine, the server was able to handle at least 200 concurrent requests without reseting the connection, and processed them at 47.46 requests/second.

With EM, 200 concurrent requests

ab -c 200 -n 1000 http://127.0.0.1:3000/devices/14/messages This is ApacheBench, Version 2.3 <$Revision: 655654 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/
Server Software:        thin
Server Hostname:        127.0.0.1
Server Port:            3000

Document Path:          /devices/14/messages
Document Length:        1310 bytes

Concurrency Level:      200
Time taken for tests:   21.072 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      1857000 bytes
HTML transferred:       1310000 bytes
Requests per second:    47.46 [#/sec] (mean)
Time per request:       4214.422 [ms] (mean)
Time per request:       21.072 [ms] (mean, across all concurrent requests)
Transfer rate:          86.06 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    2   3.3      0      10
Processing:   822 3832 839.3   4181    4368
Waiting:      413 3809 855.4   4163    4355
Total:        831 3834 836.6   4181    4375

Percentage of the requests served within a certain time (ms)
  50%   4181
  66%   4209
  75%   4221
  80%   4229
  90%   4238
  95%   4246
  98%   4267
  99%   4273
 100%   4375 (longest request)

No EM, 200 concurrent requests

ab -c 200 -n 1000 http://127.0.0.1:3000/devices/14/messages This is ApacheBench, Version 2.3 <$Revision: 655654 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 127.0.0.1 (be patient)
Completed 100 requests
apr_socket_recv: Connection reset by peer (104)
Total of 152 requests completed

No EM, 40 concurrent requests

ab -c 40 -n 1000 http://127.0.0.1:3000/devices/14/messages This is ApacheBench, Version 2.3 <$Revision: 655654 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 127.0.0.1 (be patient)
Completed 100 requests
Completed 200 requests
apr_socket_recv: Connection reset by peer (104)
Total of 239 requests completed

No EM, 35 concurrent requests

ab -c 35 -n 1000 http://127.0.0.1:3000/devices/14/messages This is ApacheBench, Version 2.3 <$Revision: 655654 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/
Server Software:        WEBrick/1.3.1
Server Hostname:        127.0.0.1
Server Port:            3000

Document Path:          /devices/14/messages
Document Length:        1310 bytes

Concurrency Level:      35
Time taken for tests:   28.071 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      1998000 bytes
HTML transferred:       1310000 bytes
Requests per second:    35.62 [#/sec] (mean)
Time per request:       982.471 [ms] (mean)
Time per request:       28.071 [ms] (mean, across all concurrent requests)
Transfer rate:          69.51 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    7  83.3      0    1000
Processing:    25  961 140.9    972    1970
Waiting:       23  958 141.0    969    1970
Total:         25  968 161.1    972    2198

Percentage of the requests served within a certain time (ms)
  50%    972
  66%    992
  75%   1009
  80%   1019
  90%   1045
  95%   1065
  98%   1099
  99%   1855
 100%   2198 (longest request)

benchling-challenge's People

Watchers

 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.