3. What’s is serverless?
Before we begin we ought to mention that the word serverless is a bit of a misnomer.
Whether you use a compute service such as Google Cloud Functions or AWS Lambda to execute
your code, or interact with an API, there are still servers running in the background.
The difference is that these servers are hidden from you,there is no infrastructure for you to think
about and no way to tweak the underlying operating system.
Someone else takes care of the nitty-gritty details of infrastructure management, leaving you to
focus on development.
devfest 2022
4. “Serverless is about running code in a
compute service and interacting with
services and APIs to get the job done.”
devfest 2022
6. “Patterns are architectural solutions to
problems in software design.
They’re designed to address common
problems found in software development”
devfest 2022
7. So what really are serverless patterns?
While there are no specific serverless patterns, it is far easier to find an answer to a problem if
everyone in the room understands which patterns are applicable, how they work, their
disadvantages and their advantages.
They are also excellent communication tools for developers working together on a solution.
Hence these patterns will make you write better serverless applications regardless of the platform
you choose to use.
devfest 2022
10. Messaging Pattern
Messaging pattern is popular in distributed systems because it allows developers to build scalable
and robust systems by decoupling functions and services from direct dependence on one another
and allowing storage of events/records/requests in a queue.
The reliability comes from that in the event the consuming service goes offline, messages are
retained in the queue and can still be processed later when the consuming service is back online.
devfest 2022
11. When to use messaging pattern
This is a popular pattern used to handle workloads and data processing.
The messaging hub (queue) serves as a buffer, so if the consuming service crashes, data isn’t lost.
It remains in the queue until the service can restart and begin processing it again.
In an environment that has a lot of data processing messages and requests, try to minimize the
number of functions that are directly dependent on other functions and use the messaging
pattern instead
devfest 2022
13. Fan-Out Pattern
Fan-out is a serverless pattern that’s familiar to many users of AWS.
Generally, the fan-out pattern is used push a message out to all listening/subscribed clients of a
particular queue or a message pipeline.
Topics are communication/messaging channels that can have multiple publishers and subscribers.
When a new message is added to a topic, it forces invocation of all subscribers in parallel, thus
causing the event to fan_out.
devfest 2022
14. When to use fan-out pattern
This pattern is useful if you need to invoke multiple functions at the same time.
A topic will try and retry to invoke your function if it fails to deliver the message or if the function
fails to execute.
Furthermore, the fan-out pattern can be used for more than just invocation of multiple functions.
Topics support other subscribers such as email and queues. Adding a new message to a topic can
invoke functions, send an email(s) or push a message to a queue, all at the same time.
devfest 2022
16. Command Pattern
The command pattern allows you to decouple the caller of the operation from the entity that
carries out the required processing.
In practice, this pattern can simplify the API Gateway implementation, because you may not want
or need to create a RESTful URI for every type of request.
The command function could work with different versions of your clients and invoke the right
function that needed by the client.
devfest 2022
17. When to use command pattern
This pattern is useful if you want to decouple the caller and the receiver
Having a way to pass arguments as an object and allowing clients to be parameterized with
different requests, can reduce coupling between components and help make the system more
extensible.
devfest 2022