Serverless - Image Recognition Engine

Bhavna Surendra Latare
7 min readApr 18, 2022

What is Serverless ?

Serverless architectures are application designs that incorporate third-party “Backend as a Service” (BaaS) services, and/or that include custom code run in managed, ephemeral containers on a “Functions as a Service” (FaaS) platform. By using these ideas, and related ones like single-page applications, such architectures remove much of the need for a traditional always-on server component. Serverless architectures may benefit from significantly reduced operational cost, complexity, and engineering lead time, at a cost of increased reliance on vendor dependencies and comparatively immature supporting services.

Serverless Architecture

Serverless Architecture is a software design model where applications are hosted by a third party, removing the need for provisioning, managing and scaling databases and servers. In this way, businesses can run their software applications via third-party services without spending on virtual or physical servers.

Serverless architecture is considered ideal for business goals, including resource allocation automation, agile work environments, improved response times and scalability. Also, it helps in reducing additional operational costs and provisioning for physical infrastructure, providing you the value for your investment.

Working of Serverless Architecture

Serverless architecture is based on a Functions-as-a-service model (FaaS) that enables cloud platforms to execute code without requiring entirely provisioned infrastructure instances. FaaS, also known as Compute as a Service (CaaS) is server-side, stateless functions that are scalable and managed completely by cloud vendors.

DevOps team writes code that emphasizes business logic and defines an event that triggers the function to be executed, such as an HTTP request. The cloud vendor then executes the code and sends results to the web app for users to review.

Cost-saving and convenience benefits related to on-demand auto-scaling resources and pay-as-you-go services make serverless architecture an ideal option for business stakeholders and DevOps teams.

AWS - Serverless Services

COMPUTE

  • Lambda on AWS
    Execute programmes without deploying or managing servers, and pay for just the resources consumed.
  • Fargate AWS
    Utilize Amazon Elastic Container Service (ECS) or Amazon Elastic Kubernetes Service to run serverless containers (EKS)

INTEGRATION OF APPLICATIONS

  • EventBridge by Amazon
    Construct an event-driven architecture that integrates data from your own applications, SaaS, and AWS services.
  • Step Functions in AWS
    Coordination of numerous AWS services into serverless processes enables rapid development and updating of applications.
  • Amazon SQS
    Enables microservices to be decoupled and scaled using message queues that transmit, store, and receive messages at any volume.
  • Amazon Social Networking Service
    Receive high-volume pub/sub, SMS, email, and mobile push alerts with confidence.
  • Gateway to the Amazon API
    At any scale, create, publish, maintain, monitor, and protect REST and Websocket APIs.
  • AWS Application Sync
    At any size, you can create, publish, administer, monitor, and protect GraphQL APIs and Subscriptions.

DATA STORAGE FACILITY

  • Amazon S3
    Amazon S3 Scalability, data availability, security, and speed are all industry-leading features of Amazon S3.
  • DynamoDB by Amazon
    This key-value and document database delivers performance in single digit milliseconds at any size.
  • Proxy for Amazon RDS
    This proxy for Amazon Relational Database Service improves scalability, resilience, and security (RDS)
  • Serverless Amazon Aurora
    Automatically scale performance relies on your application’s requirements with this Amazon Aurora setup.

Image Recognition

Image recognition is the processing of the image seen by the machine (computer) in such a way that by analyzing the digital data recording. It is possible to classify the observed objects in order to make further decisions.

Image recognition in the meaning of e.g. recognizing people on photos is actually a special case of the pattern recognition domain that applies in many areas of science. Image recognition is one of the oldest research areas in computing. Most people think of large-scale projects when they hear the term, such as engines that can identify broad categories of objects.

▶Imagine you have a website where people can upload images. As soon as the images are uploaded, you want the images to go through a set of workflow actions.

For example, a workflow where a user uploads an image which is stored in the S3 bucket triggers a Lambda function 1.

This function invokes the state function workflow, as shown in the image.

This step function workflow orchestrates the job of multiple Lambda functions. The first thing it does it to extract the metadata from the image, for example, image type information. Meanwhile, another three lambda functions are invoked in parallel.

Lambda function 2 is invoked to extract the image metadata

Lambda function 3 invokes the Rekognition which finds out the object in the image

Lambda function 4 is invoked to generate an image thumbnail

Lambda function 5 writes all this information back into the DynamoDB

Whenever the page refreshes after the user has uploaded the image, they see all the metadata, thumbnail and the object tagged that are evident in the image. This is an example of an image processing pattern and can extend it as per your custom requirements.

NatGeo relied on AWS Serverless Services

National Geographic is at the center of a community of bold people with insatiable curiosity. Furthering knowledge about and understanding of our world is, and always has been, the core purpose of National Geographic.

National Geographic Partners (NGP) reaches millions of consumers each month through global television channels, magazines in 37 different languages, and the largest social media footprint of any brand, with more than 420 million followers. NGP — a joint venture between the nonprofit National Geographic Society (NGS) and 21st Century Fox — sees its mission as helping people better understand the world and their role in it.

NGP is poised to migrate all its existing applications and IT operations from its on-premises data centers to the cloud. The company also has a cloud-first policy for new applications and plans to rethink traditional content management systems (CMS) as it embraces new approaches that better fit its multichannel, multiformat content.

Why chose AWS -Serverless service ?

  1. The immense volume of data was stored in CMSs on multiple continents and in different formats.
  2. There was a challenge with the category of content most synonymous with the NGP brand: images — especially photographs, but also maps and charts.

Working of NatGeo -Serverless Ecosystem

On the iOS and Android app — currently available only to customers of the Australian telecom Optus — users can now explore National Geographic content dating back to the first issue of the magazine, including thousands of photographs, magazine and web articles, short- and long-form videos, Instagram feeds, and exclusive app-only video content.

The app also offers granular notification settings, so users are in control of when and on what devices they receive them.

To accomplish all of this, the app makes use of multiple AWS technologies. After an upstream Node.js aggregation application normalizes incoming data for compatibility with the app’s Amazon CloudSearch indexes, the ingested files are stored as objects in Amazon Simple Storage Service (Amazon S3). AWS Lambda, a serverless compute service that runs code triggered by events, responds to Amazon S3 object creations by updating index entries in Amazon DynamoDB, a serverless, non-relational database with single-digit-millisecond responsiveness at any scale.

If the new files are images, other AWS Lambda functions direct resizing and cropping as needed. To solve the problem of insufficient image metadata, National Geographic is using Amazon Rekognition, a deep-learning computer-vision service. As another step in the platform’s image processing, AWS Lambda functions invoke Amazon Rekognition to identify and label objects, events, and concepts visible in any new images and videos detected in Amazon S3.

To deliver a highly personalized experience, the app stores user activity data and lists of favorited content in Amazon DynamoDB, where AWS Lambda functions use it to build individual user profiles and the custom Amazon CloudSearch feeds that serve the content users see in the app. User notifications are delivered using Amazon Simple Notification Service (Amazon SNS).

“Using AWS serverless computing reduced development time by months and enabled us to quickly add features that would otherwise have been out of scope,Without Amazon Rekognition, for example, it would have been challenging to serve images based on user preferences, a key part of the user experience. Serverless computing is just one way AWS is enabling us to innovate in response to constant changes in business needs and customer demands. Easy-to-use technology from AWS lets us focus on experimenting, learning, and innovating better and faster than ever.”,

says Nik Khilnani

[Senior Director of Platform Development, National Geographic Partners]

📚References

  1. Serverless Architecture - https://www.leewayhertz.com/what-is-serverless-architecture/
  2. Applications of Serverless - https://www.simform.com/blog/serverless-aws-lambda-examples/
  3. NatGeo - https://aws.amazon.com/solutions/case-studies/national-geographic/

--

--

Bhavna Surendra Latare

I am a student passionate about Programming and Development | DSA Enthusiastic | working on ML | exploring Indian Culture