Hands-On Serverless Applications with Go
eBook - ePub

Hands-On Serverless Applications with Go

Build real-world, production-ready applications with AWS Lambda

  1. 416 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Hands-On Serverless Applications with Go

Build real-world, production-ready applications with AWS Lambda

About this book

Learn to build, secure, deploy, and manage your serverless application in Golang with AWS Lambda

Key Features

  • Implement AWS lambda to build scalable and cost-efficient applications in Go
  • Design and set the data flow between cloud services and custom business logic
  • Learn to design Lambda functions using real-world examples and implementation scenarios

Book Description

Serverless architecture is popular in the tech community due to AWS Lambda. Go is simple to learn, straightforward to work with, and easy to read for other developers; and now it's been heralded as a supported language for AWS Lambda. This book is your optimal guide to designing a Go serverless application and deploying it to Lambda.

This book starts with a quick introduction to the world of serverless architecture and its benefits, and then delves into AWS Lambda using practical examples. You'll then learn how to design and build a production-ready application in Go using AWS serverless services with zero upfront infrastructure investment. The book will help you learn how to scale up serverless applications and handle distributed serverless systems in production. You will also learn how to log and test your application.

Along the way, you'll also discover how to set up a CI/CD pipeline to automate the deployment process of your Lambda functions. Moreover, you'll learn how to troubleshoot and monitor your apps in near real-time with services such as AWS CloudWatch and X-ray. This book will also teach you how to secure the access with AWS Cognito.

By the end of this book, you will have mastered designing, building, and deploying a Go serverless application.

What you will learn

  • Understand how AWS Lambda works and use it to create an application
  • Understand how to scaleup serverless applications
  • Design a cost-effective serverless application in AWS
  • Build a highly scalable and fault-tolerant CI/CD pipeline
  • Understand how to troubleshoot and monitor serverless apps in AWS
  • Discover the working of APIs and single page applications
  • Build a production-ready serverless application in Go

Who this book is for

This book is for Go developers who would like to learn about serverless architecture. Go programming knowledge is assumed. DevOps and Solution Architects who are interested in building serverless applications in Go can also choose this book.

Tools to learn more effectively

Saving Books

Saving Books

Keyword Search

Keyword Search

Annotating Text

Annotating Text

Listen to it instead

Listen to it instead

Information

Assessments

Chapter 1: Go Serverless

  1. What are the advantages of using the serverless approach?
Answer:
    • NoOps: no management or configuration overhead and faster time to market.
    • Autoscaling and HA: enhanced scalability and elasticity based on load.
    • Cost-optimization: pay only for the compute time your consume.
    • Polygot: leverage the power of nanoservices architecture.
  1. What makes Lambda a time-saving approach?
Answer: You pay per execution and you don't pay for idle resources, while with EC2 instances, you pay also for unused resources.
  1. How does serverless architecture enable microservices?
Answer: Microservices is the approach of breaking down a monolithic application into a collection of smaller and modular services. Serverless computing is a key enabled for microservices-based applications. It makes infrastructure even-driven and completely controlled by the needs of each service that makes up an application. Moreover, serverless means functions, and a microservice is a set of functions.
  1. What is the maximum time limit for an AWS Lambda function?
Answer: By default, each Lambda function has a 3 seconds timeout; the maximum duration you can set, is 5 minutes.
  1. Which of the following are supported event-sources for AWS Lambda?
    • Amazon Kinesis Data Streams
    • Amazon RDS
    • AWS CodeCommit
    • AWS CloudFormation
Answer: Amazon Kinesis Data Streams, AWS CodeCommit and CloudFormation are supported event-sources for AWS Lambda. The list of all supported event sources can be found on the following url: https://docs.aws.amazon.com/lambda/latest/dg/invoking-lambda-function.html
  1. Explain what a goroutine is in Go. How can you stop goroutines?
Answer: A goroutine is lightweight thread; it uses a resource called channel to communicate. Channels, by design, prevent race conditions from happening when accessing shared memory using goroutines. To stop a goroutine, we pass signal channel. That signal channel is used to push a value. The goroutine polls that channel regularly. As soon as it detects a signal, it quits.
  1. What's Lambda@Edge in AWS?
Answer: Lambda@Edge allows you to run Lambda functions at the edge locations of CloudFront in order to customize the content returned to your end users at the lowest latency.
  1. What's the difference between Function as a Service and Platform as a Service?
Answer: Both PaaS and FaaS allow you to easily deploy an application and scale it without worrying about the underlying infrastructure. However, FaaS saves you money because you pay only for the compute time used to handle the incoming requests.
  1. What's an AWS Lambda cold start?
Answer: Cold start happens when a new event is triggered; AWS Lambda creates and initialize a new instance or container to handle the request, which takes longer (Startup latency) compared to warm starts, where the container is reused from a previous event.
  1. Can AWS Lambda functions be stateless or stateful?
Answer: Lambda functions must be stateless to leverage the power of autoscaling due to increasing rate of incoming events.

Chapter 2: Getting Started with AWS Lambda

  1. Which format is not supported by the AWS CLI?
    • JSON
    • Table
    • XML
    • Text
Answer: The support values are JSON, table, and text. The default output is JSON.
  1. Is it recommended to use the AWS root account for everyday interaction with AWS? If yes, why?
Answer: AWS root account has the ultimate authority to create and delete AWS resources, change the billing, and even close the AWS account. Hence, it is strongly recommended to create an IAM user for everyday tasks with only the needed permissions.
  1. What environment variables do you need to set to use the AWS CLI?
Answer: The following are the required environment variables to configure the AWS CLI:
    • AWS_ACCESS_KEY_ID
    • AWS_SECRET_ACCESS_KEY
    • AWS_DEFAULT_REGION
  1. How do you use the AWS CLI with named profiles?
Answer: AWS_PROFILE can be used to set the CLI profile to use. The profile is stored in the credentials file. By default, AWS CLI uses the default profile.
  1. Explain the GOPATH environment variable.
Answer: The GOPATH environment variable specifies the location of your Go workspace. Default value is $HOME/go.
  1. Which command-line command compiles a program in Go?
    • go build
    • go run
    • go fmt
    • go doc
Answer: The as-mentioned commands do the following:
    • build: It is a compile package and dependencies and generate a single binary.
    • run: It i...

Table of contents

  1. Title Page
  2. Copyright and Credits
  3. Packt Upsell
  4. Contributors
  5. Preface
  6. Go Serverless
  7. Getting Started with AWS Lambda
  8. Developing a Serverless Function with Lambda
  9. Setting up API Endpoints with API Gateway
  10. Managing Data Persistence with DynamoDB
  11. Deploying Your Serverless Application
  12. Implementing a CI/CD Pipeline
  13. Scaling Up Your Application
  14. Building the Frontend with S3
  15. Testing Your Serverless Application
  16. Monitoring and Troubleshooting
  17. Securing Your Serverless Application
  18. Designing Cost-Effective Applications
  19. Infrastructure as Code
  20. Assessments
  21. Other Books You May Enjoy

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn how to download books offline
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 990+ topics, we’ve got you covered! Learn about our mission
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more about Read Aloud
Yes! You can use the Perlego app on both iOS and Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app
Yes, you can access Hands-On Serverless Applications with Go by Mohamed Labouardy in PDF and/or ePUB format, as well as other popular books in Computer Science & Cloud Computing. We have over one million books available in our catalogue for you to explore.