The Technology Behind Adafruit IO

io

The technology behind Adafruit IO will most likely be changing soon as we scale the service, but we thought it might be useful to share how things are currently working behind the scenes.

Website & Rest API

The Adafruit IO website and REST API are powered by a Ruby on Rails application, which is served by nginx and Phusion Passenger. The user interface for the site is currently a combination of jQuery, Backbone, and d3.  We plan on migrating to React in the near future, and will slowly be replacing jQuery and Backbone. IO users are authenticated using their adafruit.com accounts via OAuth, but the online storefront and IO are completely separate applications hosted on separate servers.

Real-time Services

Node.js is currently handling all of our real-time traffic from clients connected via MQTT or websocket. We use a modified version of Mosca as our MQTT broker, and will be switching to Aedes as soon as it is production ready. The node.js workers push data to the database by sending information to a Sidekiq queue, which is then picked up by a Ruby worker and inserted into the database using the same Active Record models that the website and REST API use.  The Ruby worker then notifies node.js of the successful database transaction via Redis, and data is emitted to the appropriate MQTT and websocket subscribers. The node.js workers are managed by pm2, and we use nginx in front of node.js to handle TLS/SSL connections for MQTT on port 8883. Node.js will also eventually handle connections from other IoT protocols like CoAP and MQTT-SN.

Databases & Caching

We use PostgreSQL for storing all data that needs to be persisted to disk. This includes things like user account data, feed metadata, and the logged data that is sent to IO from user devices. We have PostGIS extensions installed for geospatial queries, and we use wal-e for continuous backups of the database. We use Redis as the glue for the separate services. It handles connecting the separate node.js worker processes, and also handles any message passing between the Ruby and node.js processes. We also use memcached for the Rails application cache, and for storing user sessions.

Development

There are currently two developers working part-time on IO, and we use git to track our changes. We make heavy use of git branches while working on new features, and create pull requests on GitHub to summarize our changes before merging. We write unit tests using Rails’ Test::Unit, and we use Mocha for unit testing Node.js code. We use Travis CI to make sure that both Rails and Node tests pass before merging any branches into master. We use swagger for documenting our REST API, and also generate client libraries from the API docs using swagger-codegen. We mainly use HipChat for communication, and meet once a week on Google Hangouts.

Server Hardware & Administration

We currently host IO on a single server running CentOS with two 4 core Intel Xeon E3-1270 v3’s @ 3.50GHz, 16GB of RAM, and a 500GB SSD. We will most likely migrate to EC2 or DigitalOcean in the near future. We use capistrano for deploying code to the server, and the server’s configuration is managed with chef-solo. We monitor the server with New Relic, and use Mandrill for sending email. Some other administration tools we rely on heavily are htop, tmux, mosh, free, and monit.

That’s it for now. As I mentioned, these things are likely to change soon, but if you have any suggestions for modifying our current stack, please let us know.


Adafruit publishes a wide range of writing and video content, including interviews and reporting on the maker market and the wider technology world. Our standards page is intended as a guide to best practices that Adafruit uses, as well as an outline of the ethical standards Adafruit aspires to. While Adafruit is not an independent journalistic institution, Adafruit strives to be a fair, informative, and positive voice within the community – check it out here: adafruit.com/editorialstandards

Join Adafruit on Mastodon

Adafruit is on Mastodon, join in! adafruit.com/mastodon

Stop breadboarding and soldering – start making immediately! Adafruit’s Circuit Playground is jam-packed with LEDs, sensors, buttons, alligator clip pads and more. Build projects with Circuit Playground in a few minutes with the drag-and-drop MakeCode programming site, learn computer science using the CS Discoveries class on code.org, jump into CircuitPython to learn Python and hardware together, TinyGO, or even use the Arduino IDE. Circuit Playground Express is the newest and best Circuit Playground board, with support for CircuitPython, MakeCode, and Arduino. It has a powerful processor, 10 NeoPixels, mini speaker, InfraRed receive and transmit, two buttons, a switch, 14 alligator clip pads, and lots of sensors: capacitive touch, IR proximity, temperature, light, motion and sound. A whole wide world of electronics and coding is waiting for you, and it fits in the palm of your hand.

Have an amazing project to share? The Electronics Show and Tell is every Wednesday at 7pm ET! To join, head over to YouTube and check out the show’s live chat – we’ll post the link there.

Join us every Wednesday night at 8pm ET for Ask an Engineer!

Join over 36,000+ makers on Adafruit’s Discord channels and be part of the community! http://adafru.it/discord

CircuitPython – The easiest way to program microcontrollers – CircuitPython.org


Maker Business — “Packaging” chips in the US

Wearables — Enclosures help fight body humidity in costumes

Electronics — Transformers: More than meets the eye!

Python for Microcontrollers — Python on Microcontrollers Newsletter: Silicon Labs introduces CircuitPython support, and more! #CircuitPython #Python #micropython @ThePSF @Raspberry_Pi

Adafruit IoT Monthly — Guardian Robot, Weather-wise Umbrella Stand, and more!

Microsoft MakeCode — MakeCode Thank You!

EYE on NPI — Maxim’s Himalaya uSLIC Step-Down Power Module #EyeOnNPI @maximintegrated @digikey

New Products – Adafruit Industries – Makers, hackers, artists, designers and engineers! — #NewProds 7/19/23 Feat. Adafruit Matrix Portal S3 CircuitPython Powered Internet Display!

Get the only spam-free daily newsletter about wearables, running a "maker business", electronic tips and more! Subscribe at AdafruitDaily.com !



No Comments

No comments yet.

Sorry, the comment form is closed at this time.