Interview challenge: developing a system to serve high traffic of POST and GET
Sun 17 Feb 2019

This is a challenge from "XYZ" company. My solution is using message queue for "POST". For "GET", it's just a challenge, not applying in real project. Because pub/sub system would be better than developing "GET" API like this. This is the implementation for . Please have a look on that article for more details.

This guideline for MAC OS.


1. Installation


  1. Rabbitmq 3.7.9
  2. Redis
  3. Ruby 2.5.1


Installing instruction

brew install rabbitmq

Go to rabbitmq server and import this file which was included in source code.


Now we would see two exchanges:

  1. medwing.readings

Enabling plugins by copying rabbitmq_delayed_message_exchange-20171201-3.7.x.ez file in source code and paste to plugins directory. Reference.


Run this command to enable plugin.

rabbitmq-plugins enable rabbitmq_delayed_message_exchange

Looking for this plugin here if we use another Rabbitmq version

Make sure we are using correct version.

Start Rabbitmq server by this command.



Installing redis.

brew install redis

Start redis by this command.


Making sure we clear all Redis data before manual testing on development mode.

redis-cli flushall

2. Testing 

Rabbitmq and Redis are not required for testing mode. I used this trick for testing message queue

We can find message_queue_helper.rb in the source code for more details.

All we need is just run this command.

bundle exec rspec spec
Finished in 6.7 seconds (files took 2.4 seconds to load)
36 examples, 0 failures

3. Development

Please respond 'y' when you run db:setup or any other commands which don't need rabbitmq.

rails db:setup

Starting rabbitmq and redis servers.


Starting rails server and workers.

foreman start -f

Let's give it a try by using postman. 




One more.

Average = (200+600)/2 = 400

If we do the same with thermostat_id = 2, we would see the sequence number like below.


Why sneakers?