Database as a Microservice: Stateless in a Stateful World

Stephen Goldberg Stephen Goldberg
June 8, 2018 IoT & Automation

Ready to learn Internet of Things? Browse  IoT Training and Certification courses developed by industry thought leaders and Experfy in Harvard Innovation Lab.

Evolution of Stateless Computing

Microservices have become dominant over the last few years, so much so that it is hard to imagine encountering a modern application built with a SOAP API. The wide spread usage of stateless microservices has allowed for modern applications to be easily and quickly deployed horizontally and directly on the edge.  The lightweight nature of REST APIs due to their statelessness, have allowed for applications with less overhead, quicker integration times, and a much more enjoyable programming experience.  Microservice adoption at both the application and middleware layer have driven much of the advances in edge computing.

Databases living in a Past State

Databases on the other hand are lagging behind.  Many databases today still rely on statefulness which prevents them from being utilized directly as part of a microservice architecture.  Often it makes more sense for developers to buffer them with a middleware layer or in some cases even a caching database to protect both the database and the application.   

This has major disadvantages from a capital and performance perspective.  Companies have invested heavily in IoT devices; yet need to double that spending on cloud infrastructure. Furthermore, we have heard from developers where latency between the edge and the cloud is causing usability issues as well as crashes in some cases. 

Most SQL databases today, like VoltDB and SAP HANA, are heavily focused on in-memory indexes, which is great for a read only scenario, but suffers massively under a read/write or HTAP scenario. The statefulness of these in-memory databases create problems like out of memory exceptions which lead to crashes, and make them an unreliable platform to directly call as a microservice.  Furthermore, because of their statefulness, when recovering from crashes they take a long time to restore state, and as a result can lead to a long outage.  

NoSQL databases do not suffer from these same problems generally. However, they are difficult to use as HTAP databases as they are slow when attempting to perform advanced analytics and querying due to their structure.  Trying to use them for advanced analytics requires a lot of CPU and memory when performing multi-table queries or complex filters.  This makes it risky to use them as a microservice back end or IoT Database as this could lead to crashes.  The memory and CPU usage is due to their need to transform the data from a NoSQL model to a SQL model; hence the term multi-model. 

To solve these problems in edge computing and industrial IoT most developers today are relying on some form of caching mechanism on the edge, and then migrating their data from their IoT devices back to the cloud to live in their data warehouse.  This is expensive, complex, and slow. 

Middleware and ORM Slowing You Down

Another reason most folks do not use databases directly on the edge as a microservice platform is because they need ORMs and middleware to communicate to them.  While many databases today might support REST APIs it is not necessarily their recommended protocol.  As a result developers need some way to transform result sets returned by databases into usable objects. Often they will rely on ORM tools like Hibernate (http://hibernate.org/) or Mongoose (http://mongoosejs.com/).  These tools are terrible on performance and require a lot of overhead.  It would be ill advised to attempt to run an ORM directly on the edge.  In addition to their performance impact they require a lot of configuration and maintenance, and in an Industrial Internet of Things use case where you could have millions of connected devices it would be a nightmare to maintain an ORM on each of them. 

  • Experfy Insights

    Top articles, research, podcasts, webinars and more delivered to you monthly.

  • Stephen Goldberg

    Tags
    Internet of Things
    © 2021, Experfy Inc. All rights reserved.
    Leave a Comment
    Next Post
    Managing Cybersecurity in the Age of the Distributed Team

    Managing Cybersecurity in the Age of the Distributed Team

    Leave a Reply Cancel reply

    Your email address will not be published. Required fields are marked *

    More in IoT & Automation
    IoT & Automation
    Could the IoT Help End Hunger? Farmers Are Finding Out

    Internet of Things (IoT) gadgets are everywhere. Cars, buildings, roadways, airplanes, home appliances, and other items have tens of billions of sensors, processors, and internet-connected gadgets. IoT devices detect motion, regulate temperature, share and collect data, measure weather, and provide location information, power logistics, and medical research. They also enable self-driving vehicles, to name just

    5 MINUTES READ Continue Reading »
    IoT & Automation
    10 Biggest Opportunities for IoT Innovation in 2021

    IoT is a powerful economic driver. IoT Innovation is actively shaping businesses and consumer trends. Most of the technologies developed before and during the pandemic address the Internet of Things directly or indirectly. From healthcare and retail to automobile and manufacturing, IoT innovations are opening new avenues across industries.  It covers almost every segment of

    8 MINUTES READ Continue Reading »
    IoT & Automation
    10 Things to Consider When Starting an IoT Project

    One of the biggest issues companies face when starting an IoT project is deciding who should be responsible. Should it be the engineering team that is responsible for the core technicalities of the device, or should it be the product management team that is responsible for the end functionalities of the IoT product? Starting on

    8 MINUTES READ Continue Reading »

    About Us

    Incubated in Harvard Innovation Lab, Experfy specializes in pipelining and deploying the world's best AI and engineering talent at breakneck speed, with exceptional focus on quality and compliance. Enterprises and governments also leverage our award-winning SaaS platform to build their own customized future of work solutions such as talent clouds.

    Join Us At

    Contact Us

    1700 West Park Drive, Suite 190
    Westborough, MA 01581

    Email: [email protected]

    Toll Free: (844) EXPERFY or
    (844) 397-3739

    © 2025, Experfy Inc. All rights reserved.