Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Building Serverless Applications with Python

You're reading from   Building Serverless Applications with Python Develop fast, scalable, and cost-effective web applications that are always available

Arrow left icon
Product type Paperback
Published in Apr 2018
Publisher
ISBN-13 9781787288676
Length 272 pages
Edition 1st Edition
Languages
Concepts
Arrow right icon
Author (1):
Arrow left icon
Jalem Raj Rohit Jalem Raj Rohit
Author Profile Icon Jalem Raj Rohit
Jalem Raj Rohit
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. The Serverless Paradigm 2. Building a Serverless Application in AWS FREE CHAPTER 3. Setting Up Serverless Architectures 4. Deploying Serverless APIs 5. Logging and Monitoring 6. Scaling Up Serverless Architectures 7. Security in AWS Lambda 8. Deploying a Lambda Function with SAM 9. Introduction to Microsoft Azure Functions 10. Other Books You May Enjoy

Serverless architectures don't have to be real-time only

Serverless architectures generally are leveraged as real-time systems as they work as a function as service which is triggered by a set of available triggers. However, this is a very common misconception, as serverless systems can be leveraged equally well both as real-time and batch architectures. Knowing how to leverage the concept of serverless systems as batch architectures will open up many engineering possibilities, as all engineering teams don't necessarily need or have real-time systems to operate.

Serverless systems can be batched by leveraging the following:

  • The cron facility in triggers
  • The concept of queues

Firstly, let's understand the concept of the cron facility in triggers. Serverless systems on the cloud have the ability to set up monitoring, which enables the trigger to get triggered every few minutes or hours and can be set as a normal cron job. This helps in leveraging the concept of serverless as a regular cron batch job. In the AWS environment, Lambda can be triggered as a cron via AWS CloudWatch, by setting the frequency of the cron by manually entering the time interval as the input and also by entering the interval in the cron format:

One can also leverage the concept of queues when building serverless batch architectures. Let's understand this by setting an example data pipeline. Let's say the system which we intend to build does the following tasks:

  1. A user or a service sends some data into a database or a much simpler data store, such as AWS's S3.
  2. Once there are more than 100 files in my data store, we'll want to do some task. Let's say, doing some analytics on them, for example, such as counting the pages.

This can be achieved via queues, and this is one of the simpler serverless systems we can consider as an example. So, this can be achieved as follows:

  1. The user or the service uploads or sends the data to the data store which we have selected.
  2. A queue is configured for the purpose of this task.
  3. An event can be configured to S3 buckets or data stores so that as soon as data enters into the store, a message is sent to the queue which we have configured earlier.
  4. Monitoring systems can be set to monitor the queue for the number of messages in it. It is advisable to use the monitoring system of the cloud provider you are using so that the system stays completely serverless.
  5. Alarms can be set to the monitoring systems, configuring a threshold for these alarms. For example, the alarm needs to be triggered whenever the number of messages in our queue reaches or exceeds 100.
  6. This alarm can act as a trigger to the Lambda function which does the analytics by first receiving messages from the queue and then querying the data store using the filename received from the message.
  7. Once the analytics are completed on the files, the processed files can be pushed to another data store for storage.
  8. After the entire task is completed, the container or the server where the Lambda function has run will be terminated, thus making this pipeline completely serverless.
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image