Serverless and Application Services Flashcards
What does a “Monolithic Architecture” mean?
What are some caveats?
It’s basically an app built from one single combined block of services.
- if any component of app fails, then entire app fails
- if one component needs to scale, you must scale the whole app
- components are always running and billed together
REVIEW:
What does a “Tiered Architecture” mean?
○ The monolithic architecture is broken apart into a collection of Tiers - these can be on the same server or on different servers
○ Each Tier connects to a single endpoint of another tier so they can trade data; separate but still tightly coupled (direct line of comms i.e SYNCHRONOUS Communications must be maintained)
○ Each tier can be vertically scaled independent of the other tiers
○ Allows you to use Internal LB’s between the different Tiers; one tier no longer communicates with a specific instance, but rather, with a LB –> this allows for Horizontal Scaling very easily
○ You can’t scale a tier all the way down to ZERO, and there always has to be at minimum ONE connection between the Tiers – remember the tiers are communicating SYNCHRONOUSLY
What are “Queues” within a Tiered ARCH?
Queues allow for Asynchronous Communications and is how we get around the Synchronous Comms requirement of a Tiered ARCH.
EX) When a user makes a request, the Upload Tier will send a message to the Queue where the Processing Tier will then get the job and execute the job once it gets to the front of the line in the Queue.
As projects get completed, they get deleted from the queue.
Queues are FIFO designed.
Can internal LB’s be used within a Tiered ARCH that’s taking advantage of Queues?
No - no communications happen directly where components are completely decoupled.
What is a Microservices ARCH?
An architecture that is comprised of Microservices.
Microservices are tiny, self-service app instances that perform individual tasks very fast and very well.
What 3 high-level components are Event-Driven ARCH comprised of?
Producers - components of the app that might interact with customers, or parts of the infra (like EC2’s)
Consumers - SW waiting for events to occur; if they see an event they care about, they will take an action (like displaying something for a customer)
Both - this could be an API
Are Producers and Consumers in an Event-Driven ARCH always running?
No - they don’t sit around running idly waiting for stuff to happen; they are not constantly consuming resources.
They only consume resources during EVENTS aka when they are required; default status is basically “Off” or an idle/dormant state.
What triggers Producers?
Consumers?
Producers get triggered when something happens (a button is clicked).
Consumers trigger when something is sent to them where they then take an action.
What facilitates the conversations between a Producer and a Consumer?
Event Router
Event-Driven ARCH Summary
→ No constant running or waiting for things to happen
→ Producers generate events when something happens (like a click, or when an error occurs); actions get taken on that event
→ Events are delivered to Consumers, usually by an Event Router
→ Consumers can then execute a corresponding action
What is AWS Lambda?
“Function-as-a-Service” product/service that is driven by Events, which is called “Invocation” ; this service accepts Functions.
What is a Function?
What is a Lambda Function?
A small piece of code.
A small piece of code in ONE particular language running in AWS.
Where do Lambda functions run? How are you billed for Lambda functions running in this environment?
Runtime Environment - This is a “virtual environment” that’s always ready to go.
You’re only billed for the duration that the function runs for i.e if the function requires a compute activity to be triggered for 5 seconds, you’re only billed for those 5 seconds.
This is unlike EC2, where you provision the resource and then pay for that instance whether it’s running or not.
LAMBDA Key Points
– Lambda is the key component/service of AWS Serverless ARCH
– you would use Lambda as an alternative to running compute jobs on EC2 for compute needs
– Best practice is to make a Lambda function super specialized - very small but very good at doing one single task
– When a Lambda function is invoked, it runs inside of a Runtime Environment where the Runtime Environment matches the language that the function was written in.
– Always assume that that each time a function is invoked, the runtime environment is clean i.e nothing is stored in it from a previous function; STATELESS
– Runtime environments will get CPU and Memory allocated to them.. they’re like a container. The more Memory that gets added, the more CPU gets added along with it, which means it costs more for every second of duration a function is running for if there’s a lot of memory and compute added to the environment
– Any permanent data that results from a Lambda function should be sent to a persistent data store, like S3
What is the Lambda execution limit (how long it takes to execute a given function)?
15 min.
Any compute needed for 15 min or less, Lambda is a great alternative.
LAMBDA SUMMARY
· 15-minute execution limit
· Assume you get a new runtime environment for every execution; don’t rely on any data persistence
· Execution Roles (IAM Role) is assumed anytime a function is executed
○ any code inside the runtime environment can use the permissions given by the execution role
○ this is how Lambda interacts with other AWS services
- Always load data from other services
- Always store data to other services
- Always assume the Runtime Environment is never persistent
· Lambda comes under the free tier:
○ Up to 1M requests per month
○ 400,000 GB seconds of compute per month
What are Cloudwatch Events?
Delivers a near real-time stream of system events, where an event describes a change in AWS products or services.
EX) when an EC2 instance is terminated/started/stopped
What is Event Bridge?
A service that’s replacing CW Events; does the same function as CW events but also adds additional capability - events from 3rd parties and/or custom applications running in AWS.
(CW Events - delivers a near real-time stream of system events, where an event describes a change in AWS products or services)
Same basic underlying ARCH as CW events
CW Events and Event Bridge Summary
→ CloudWatch Events and EventBridge have visibility over events generated by supported AWS services within an account.
→ They can monitor the default account event bus - and pattern match events flowing through and deliver these events to multiple targets.
→ They are also the source of scheduled events which can perform certain actions at certain times of day, days of the week, or multiple combinations of both… at “x” time of day trigger “y” event
→ Both services are one way how event driven architectures can be implemented within AWS.
What is an API?
A way that you can take an app you develop, and provide it’s functionality directly to users or other system utilities or other applications to include that functionality inside their code – basically allows 2 apps to talk to each other
Computing interface that defines interactions between multiple software intermediaries. It defines the kinds of calls or requests that can be made, how to make them, the data formats that should be used, the conventions to follow, etc.
An API is basically a piece of code that sits on a server and give Apps & services a formal way to communicate with each other
How do API’s influence AWS?
API’s are how different services interact.. they are what cause AWS services to do things.
EX) when you request that AWS stop an EC2, a message gets sent to the AWS service via the AWS API in that region