In the previous article, introducing serverless applications, we took a look at what Serverless is, the value it promises, and the considerations you must make before diving in headlong. With a new paradigm like Serverless, it is reasonable to dismiss it as not applicable to an established company and application. A startup might have the luxury to go Serverless from day one, but a company with mature products and services cannot just rebuild an application much less a team with existing expertise. It is hard to step back given this context and think about all the possible scenarios that Serverless could be applicable. In this article, we are going to explore some ideal use cases for Serverless with scope ranging from a full solution back end to just the glue between existing services.
Backend as a Service (BaaS)
One of the first and significantly adopted applications of Serverless is the Mobile Backend as a Service (MBaaS) offerings. Facebook’s Parse Platform (now officially shut down and open sourced) and Google’s Firebase are two well-known examples. These platforms seek to provide everything a mobile application developer needs to create a full featured app without having to worry about anything on the back end. They take care things like data access and storage, backup, authentication and authorization, real-time messaging, and analytics. The MBaaS platforms allow companies to create mobile apps at a fraction of the cost without sacrificing powerful features that are only possible with back end supported solutions. Firebase is a compelling solution for this use case. In fact, Firebase’s capabilities have recently expanded to include things like static file hosting, file upload and storage, and generic compute functions that allow developers to create just about anything a solution might require on the back end. For instance, it is now possible to build a single-page web application on top of Firebase.
Almost any large application has some asynchronous file processing happening at least periodically. Whether for generating thumbnails from uploaded images, scanning log files or something else, file processing can be critical for preparing and analyzing data. Serverless compute functions with their event based triggers are a perfect fit for these processes. In AWS you can configure a Lambda function to run based on an S3 create object event. When your existing application uploads an image to S3, your Lambda function can be triggered by this event to create the necessary thumbnails. This event based Serverless process reduces load and unused capacity from existing server resources, only incurs a cost for the actual processing done and is automatically and elastically scaled to handle any load. Similar flows can be created for log or other data file processing.
Data Ingestion Pipelines
Data ingestion and processing pipelines are critical to large systems and are often able to be built or extracted to be stand alone. In AWS you can expose an HTTP Post endpoint in API Gateway that triggers a Lambda function to push this data into a Kinesis stream. You can then create other Lambda functions to process the data from one or more streams to perform anything from storing the data in a database to pushing the data to your CRM. The event-driven and single-purpose nature of Serverless compute functions make them ideal for processing pipelines.
Chatbots are a fun application of Serverless to start with as you are learning this new paradigm and the related technologies. In a few hours, you can create a Slackbot that deploys a branch of code to a staging server or notifies your team in Slack that an AWS CloudWatch alarm was triggered.
These chatbots can get very sophisticated and drive e-commerce interactions with real customers. For instance, you can use Facebook Messenger to update a customer on the status of an order they placed on your website. With chatbots, this communication does not have to be one way anymore. Now your customer can respond to order status updates with general questions, get tracking details, or jump to your store and continue shopping.
Besides the specific examples mentioned above, Serverless is useful as a general purpose service glue for connecting just about anything without the need for complex and bloated integration platforms. Any problem that benefits from parallel processing is a potentially good fit for Serverless since Serverless architectures have statelessness and scalability at their core. Before you create that next cron job or bolt on some more code to your existing monolith, you should give Serverless another consideration.