Ilovepdf Merged
Ilovepdf Merged
Microservices
2. Testing is very simple - Just launch the application and start end-to-end testing. We can also do test automation
using Selenium without any difficulty.
3. Deploying the monolithic application is straightforward - Just copy the packaged application to the server.
4. Scalability is simple - We only need to have a new instance of the monolithic application and ask the load
balancer to distribute load to the new instance as well. However, as the monolithic application grows in size,
scalability becomes a serious issue.
Monolithic architecture worked successfully for many decades. In fact, many of the most successful and largest
applications were initially developed and deployed as a monolith.
But serious issues like flexibility, reliability and scalability have led to the emergence of microservices architecture.
FUNDAMENTALS OF SCALABLE COMPUTING
Microservices Architecture
Microservices are small services that work together but are independent, and are
components or processes of an application. They have benefits of dynamic scalability,
Reliability etc. as discussed later.
These services are built around business capabilities and independently deployable
by fully automated deployment machinery.
- Martin Fowler
FUNDAMENTALS OF SCALABLE COMPUTING
Benefits of Microservices Architecture
1. Flexibility:
Microservices architecture is quite flexible. Different microservices can be developed in different
technologies. Since a microservice is smaller, the code base is quite less, so it’s not that difficult to upgrade the
technology stack versions. Also, we can incrementally adopt a newer technology without much difficulty.
2. Reliability:
Microservices architecture can be very reliable. If one feature goes down, the entire application doesn’t go
down. We can fix the issue in the corresponding microservice and immediately deploy it.
3. Development speed:
Development is pretty fast in microservices architecture. Since the volume of code is much less for a
microservice, it’s not difficult for new team members to understand and modify the code. They become
productive right from the start. Code quality is maintained well. The IDE is much faster. A microservice takes
much less time to start up. All these factors considerably increase developers' productivity.
FUNDAMENTALS OF SCALABLE COMPUTING
Benefits of Microservices Architecture (contd.)
5. Scalability:
Scalability is a major advantage in microservice architecture. Each microservice can be scaled individually.
Since individual microservices are much smaller in size, caching becomes very effective.
6. Continuous deployment:
Continuous deployment becomes easier. In order to update one component, we have to redeploy only
that particular microservice.
FUNDAMENTALS OF SCALABLE COMPUTING
An example of a Microservices Architecture
Monolithic Architecture
• It is considered to be a traditional way of building applications.
• A monolithic application is built as a single and indivisible unit. Usually,
such a solution comprises a client-side user interface, a server side-
application, and a database.
Microservices Architecture
• While a monolithic application is a single unified unit, a microservices
architecture breaks it down into a collection of smaller independent
units.
• These units carry out every application process as a separate service. So
all the services have their own logic and the database as well as
perform the specific functions.
FUNDAMENTALS OF SCALABLE COMPUTING
Comparison with SOA
Microservice architecture is generally considered an evolution of SOA as its services are more fine-grained and
function independently of each other.
Service-oriented architecture was largely created as a response to traditional, monolithic approaches to building
applications. SOA breaks up the components required for applications into separate service modules that
communicate with one another to meet specific business objectives.
FUNDAMENTALS OF SCALABLE COMPUTING
Comparison with SOA
▪ In a distributed computing environment like the Cloud, where the hardware infrastructure typically
configured as a cluster with different system architectures like a client-server or master-slave or say
a P2P architecture, there exists a significant interactions between the components or machines
involving data flows from one system to another which could be through messages or events.
▪ These data flows could happen using different protocols such as HTTP, AMQP (Advanced Message
Queuing Protocol, or a binary protocol like TCP and with different data formats.
▪ There are also different styles or natures through which these communication may happen like
synchronous or asynchronous or based on the request and number of processors of the service
▪ If the application is a monolith with multiple processes, simple intra-system IPC mechanism may
work to communicate with processes which need to interact, but when built as a set of say
microservices maybe running on different systems, communication mechanisms which can support
Inter-service communication would be essential
Ref: https://docs.microsoft.com/en-us/dotnet/architecture/microservices/architect-microservice-container-applications/communication-in-microservice-architecture
https://chanakaudaya.medium.com/a-futuristic-view-of-building-distributed-systems-with-messaging-560d0652513a
FUNDAMENTALS OF SCALABLE COMPUTING
Enterprise Service Bus
• One does not open a channel between source and destination, but rather inject a message into the bus with enough
information to allow it to be delivered correctly
• The injection is performed by code loaded into each service and represented by the filled ovals as client interfaces
• The use of multiple brokers allows the bus to scale to many clients (services) and large message traffic.
• Note that the brokers are “just” special servers/services that receive messages and perform needed transformations and
routing on them and send out new messages.
• There is a special (simple) case of message buses where the brokers shown are not separate servers but are included in
the client software. Note that such buses support not just point-to-point messaging but broadcast or selective multicast to
many recipient clients (services)
FUNDAMENTALS OF SCALABLE COMPUTING
Interaction styles
First dimension
1. One-to-one : Each client request is processed by exactly one service
2. One-to-many : Each request is processed by multiple services
Second dimension
1. Synchronous : The client expects a timely response from the service and might even block while it waits.
2. Asynchronous : The client doesn’t block, and the response, if any, isn’t necessarily sent immediately.
FUNDAMENTALS OF SCALABLE COMPUTING
One-to-one interaction
1. Request/response— A service client makes a request to a service and waits for a response. The client
expects the response to arrive in a timely fashion. It might event block while waiting. This is an
interaction style that generally results in services being tightly coupled.
3. One-way notifications— A service client sends a request to a service, but no reply is expected or sent.
FUNDAMENTALS OF SCALABLE COMPUTING
One-to-many interaction
- Publish/async responses— A client publishes a request message and then waits for a
certain amount of time for responses from interested services.
FUNDAMENTALS OF SCALABLE COMPUTING
Interaction styles
1.Synchronous (request-response) :
▪ Synchronous messaging means that the system which is
sending the message expects an immediate response from
the target system.
▪ Source system sends a message (request) to the target system and waits (blocks) until it receives
a response from the target system.
▪ Target system may process the message within itself or send the message to another system and
generate a response within a short time period.
▪ To make this communication successful and make sure source system does not waste its
resources in case of a target system failure, there is a timeout configured at the source side so
that it will stop waiting for the response if the timeout is elapsed without receiving a response
from the target system.
▪ There are variants of this like with call-back and full-duplex, which you could go through
https://chanakaudaya.medium.com/a-futuristic-view-of-building-distributed-systems-with-messaging-560d0652513a
FUNDAMENTALS OF SCALABLE COMPUTING
Synchronous (Request – response)
▪ Request-response style communication can be implemented in a blocking manner as well
as non-blocking manner.
▪ Blocking style: Instead of waiting for the response, source system can continue its work
while registering a callback in the source system side so that whenever there is a response
available from the target, this callback gets executed and the source system can continue
processing the response. This is the common pattern of implementation of most request-
response style systems because it does not blocks the resources (CPU) on the source side
instead continue utilizing resources for other tasks.
https://chanakaudaya.medium.com/a-futuristic-view-of-building-distributed-systems-with-messaging-560d0652513a
FUNDAMENTALS OF SCALABLE COMPUTING
Synchronous (Request – response)
▪ The latest improvement in the synchronous or request-response style of messaging is the full-
duplex style of messaging where both source and target systems can communicate via the same
connection at the same time.
▪ In both the above mentioned blocking and callback based synchronous messaging architectures,
one system can communicate at a given time through the connection which we called as half-
duplex or simplex.
▪ But this style of communication was not enough for modern web applications with high data
demands. The protocols like Websockets and HTTP/2 are designed in this manner.
▪ Messaging style improved the performance of the web applications through various technologies
like
▪ Request multiplexing, Header compression, Server Push, Request prioritization
https://chanakaudaya.medium.com/a-futuristic-view-of-building-distributed-systems-with-messaging-560d0652513a
FUNDAMENTALS OF SCALABLE COMPUTING
Interaction styles
2. Asynchronous :
▪ The client doesn’t block, and the response, if any, isn’t necessarily sent immediately
▪ This supports high rates of data flow.
▪ The expectations of these type of messages are
▪ Guaranteed delivery
▪ Extensive processing
▪ Correlation and time series analysis
▪ Decoupling of source and target systems
▪ These could be of the types
▪ Publish Subscribe (based on topics)
▪ Message Queues
▪ Event based real time processing (not planned for discussion)
▪ Batch Processing
▪ Store and Forward https://chanakaudaya.medium.com/a-futuristic-view-of-building-distributed-systems-with-messaging-560d0652513a
FUNDAMENTALS OF SCALABLE COMPUTING
Asynchronous vs Synchronous messaging
- Reduced coupling: The message sender does not need to know about the consumer.
- Multiple subscribers: Using a pub/sub model, multiple consumers can subscribe to receive events.
- Failure isolation: If the consumer fails, the sender can still send messages. The messages will be
picked up when the consumer recovers. Asynchronous messaging can handle intermittent downtime.
Synchronous APIs, on the other hand, require the downstream service to be available or the
operation fails.
- Load leveling: A queue can act as a buffer to level the workload, so that receivers can process
messages at their own rate.
FUNDAMENTALS OF SCALABLE COMPUTING
Asynchronous vs Synchronous messaging
- Coupling with the messaging infrastructure: Using a particular messaging infrastructure may cause
tight coupling with that infrastructure. It will be difficult to switch to another messaging
infrastructure later.
- Latency: End-to-end latency for an operation may become high if the message queues fill up.
- Complexity: Handling asynchronous messaging is not a trivial task. For example, handling of
duplicated messages, or correlating request and response messages using a separate response
queue.
- Throughput: If message queues are used, each message requires at least one queue operation and
one dequeue operation. Moreover, queue semantics generally require some kind of locking inside
the messaging infrastructure.
FUNDAMENTALS OF SCALABLE COMPUTING
Messaging models
1. Message Queues
A message queue is a form of asynchronous service-to-service communication used in serverless and microservices
architectures.
Messages are stored on the queue until they are processed and deleted.
Message queues can be used to decouple heavyweight processing, to buffer or batch work, and to smooth spiky
workloads.
• A message queue provides a lightweight buffer which temporarily stores messages, and endpoints
that allow software components to connect to the queue in order to send and receive messages.
• The messages are usually small, and can be things like requests, replies, error messages, or just plain
information.
• To send a message, a component called a producer adds a message to the queue. The message is
stored on the queue until another component called a consumer retrieves the message and does
something with it.
• Many producers and consumers can use the queue, but each message is processed only once, by a
single consumer. For this reason, this messaging pattern is often called one-to-one, or point-to-
point, communications.
• When a message needs to be processed by more than one consumer, message queues can be
combined with Pub/Sub messaging in a fanout design pattern.
FUNDAMENTALS OF SCALABLE COMPUTING
Publish-Subscribe https://aws.amazon.com/pub-sub-messaging/
1. Topic – An intermediary channel that maintains a list of subscribers to relay messages to that
are received from publishers. There can be different topic channels & different subscribers can
look at their interested topics
2. Message – Serialized messages sent to a topic by a publisher which has no knowledge of the
subscribers
4. Subscriber – An application that registers itself with the desired topic in order to receive the
appropriate messages
FUNDAMENTALS OF SCALABLE COMPUTING
Publish-Subscribe (contd.)
Advantages
1. Loose coupling
Publishers are never aware of the existence of subscribers so that both systems can operate
independently of each other. This methodology removes service dependencies that are present in
traditional coupling.
For example, a client generally cannot send a message to a server if the server process is not
running. With pub/sub, the client is no longer concerned whether or not processes are running on the
server.
2. Scalability
Pub/sub messaging can scale to volumes beyond the capability of a single traditional data center.
This level of scalability is primarily due to parallel operations, message caching, tree-based routing,
and multiple other features built into the pub/sub model.
FUNDAMENTALS OF SCALABLE COMPUTING
Publish-Subscribe (contd.)
3. Eliminate Polling:
Message topics allow instantaneous, push-based delivery, eliminating the need
for message consumers to periodically check or “poll” for new information and
updates.
This promotes faster response time and reduces the delivery latency that can be
particularly problematic in systems where delays cannot be tolerated.
4. Dynamic Targeting
Instead of maintaining a roster of peers that an application can send messages to,
a publisher will simply post messages to a topic.
Then, any interested party will subscribe its endpoint to the topic, and start
receiving these messages.
Subscribers can change, upgrade, multiply or disappear and the system
dynamically adjusts.
FUNDAMENTALS OF SCALABLE COMPUTING
Publish-Subscribe (contd.)
6. Simplify Communication
Communications and integration code is some of the hardest code to write. The
Publish Subscribe model reduces complexity by removing all the point-to-point
connections with a single connection to a message topic, which will manage
subscriptions to decide what messages should be delivered to which endpoints.
Fewer callbacks results in looser coupling and code that’s easier to maintain and
extend.
FUNDAMENTALS OF SCALABLE COMPUTING
Redis https://aws.amazon.com/redis/
Redis, which stands for Remote Dictionary Server, is a fast, open-source, in-memory key-value data store
for use as a database, cache, message broker, and queue.
• The Oracle Publish-Subscribe Model is a messaging pattern used to facilitate communication between
different applications or systems, particularly in scenarios where data needs to be sent from one system (the
publisher) to multiple recipients (the subscribers).
• It is commonly used in event-driven architectures, message-driven middleware, and real-time data
streaming.
• In Oracle's ecosystem, the publish-subscribe model is commonly applied in technologies like Oracle Advanced
Queuing (AQ), Oracle Cloud Messaging, and Oracle Service Bus, among others.
FUNDAMENTALS OF SCALABLE COMPUTING
RabbitMQ
RabbitMQ is an open-source message-broker software that originally implemented the Advanced
Message Queuing Protocol (AMQP) and has since been extended to support Streaming Text
Oriented Messaging Protocol (STOMP), MQ Telemetry Transport (MQTT) and other protocols.
• Services: The building blocks of SOA, each responsible for a specific function. These can be web services,
microservices, or other service types.
• Orchestration: This involves the coordination and sequencing of different services to achieve a business
process. Workflow orchestration engines (e.g., BPM engines, workflow managers) are responsible for
organizing and managing the sequence of service calls in a specific workflow.
• Business Process Execution Language (BPEL): A standard for defining workflows in SOA, BPEL is often used
to describe the logic of service interactions, including handling conditions, loops, and exception
management.
• Messaging and Communication: Workflows in SOA rely on asynchronous or synchronous communication
mechanisms, such as SOAP, REST, or message queues, to pass messages between services.
• Process Automation: Services in the workflow can be triggered automatically based on certain events, such
as a new request, time-based conditions, or input from other services.
FUNDAMENTALS OF SCALABLE COMPUTING
Basic Workflows Concepts
https://aws.amazon.com/what-is/service-oriented-architecture/
FUNDAMENTALS OF SCALABLE COMPUTING
Workflow Standards
• A workflow standard refers to a set of guidelines, rules, and
specifications that govern how workflows should be designed,
implemented, and executed within an organization or across
different systems. These standards aim to ensure that workflows
are efficient, interoperable, scalable, and maintainable. By
adhering to a standard, workflows can be consistently defined,
automated, and integrated across various systems and platforms.
• Web service-related standards proposed by OASIS, OMG and W3C
- interoperability was achieved by complete specification of
service features
• This goal produced heavyweight architectures
• Today, greater emphasis is put on lightweight systems where
interoperability is achieved by ad hoc transformations where
necessary
FUNDAMENTALS OF SCALABLE COMPUTING
Workflow Architecture and Specification
• Most workflow systems have two key components corresponding to the language and runtime
components of any programming environment.
• We can call these components the workflow specification and workflow execution engine
• They are linked by interfaces which could be specified by documents using, for ex: BPEL
Workflow Specification
• Scripting-based workflow systems can specify workflow in traditional language syntax similar to Python,
JavaScript, or Perl.
• One can also directly specify the (XML) interface document driving the execution engine, although that is
pretty low-level. However, most workflow systems use a graphical interface as illustrated in Figure (next
slide)
FUNDAMENTALS OF SCALABLE COMPUTING
Workflow Architecture and Specification
Workflow Specification
• Each step is a “large” activity (i.e., a service) illustrating that workflow is a programming system at a
very different granularity from familiar languages such as C++.
• Scripting languages are often used for specifying coarse-grained operations, which “explains” why
scripting is a popular approach to specifying workflows.
FUNDAMENTALS OF SCALABLE COMPUTING
Workflow Architecture and Specification
• Amazon Simple Workflow Service (Amazon SWF) makes it easy to build applications that coordinate work across
distributed components.
• In Amazon SWF, a task represents a logical unit of work that is performed by a component of an application.
• Coordinating tasks across the application involves managing intertask dependencies, scheduling, and concurrency
in accordance with the logical flow of the application.
• Amazon SWF gives full control over implementing tasks and coordinating them without worrying about underlying
complexities such as tracking their progress and maintaining their state.
• Using Amazon SWF, you implement workers to perform tasks. These workers run on cloud infrastructure, such as
Amazon EC2
• Amazon SWF stores tasks and assigns them to workers when they are ready, tracks their progress, and maintains
their state, including details on their completion. To coordinate tasks, you write a program that gets the latest state
of each task from Amazon SWF and uses it to initiate subsequent tasks
Ref: https://docs.aws.amazon.com/amazonswf/latest/developerguide/swf-dev-about-workflows.html
THANK YOU
Example:
• A file system could be considered a key-value store if you think of the file path as the key and
the file contents as the value
FUNDAMENTALS OF SCALABLE COMPUTING
DynamoDB
• Scalability: DynamoDB can automatically scale to accommodate workloads of any size without requiring you to
manually manage the scaling process. It automatically adjusts throughput capacity based on demand, and it can
handle millions of requests per second with ease.
• Fully Managed: AWS takes care of all the administrative tasks, including hardware provisioning, setup, configuration,
and patching, so you don’t need to worry about the low-level details. This makes it very developer-friendly.
• Low Latency: DynamoDB offers low-latency data access, usually in the single-digit millisecond range, making it ideal
for applications that require fast responses.
• Flexible Data Model: DynamoDB supports both key-value and document data models. You can store structured or
semi-structured data and retrieve it based on primary key values, which is very efficient for high-throughput
workloads.
• Global Availability: DynamoDB offers global tables, which replicate data across multiple AWS regions for highly
available and low-latency access from anywhere in the world.
FUNDAMENTALS OF SCALABLE COMPUTING
Key features of DynamoDB
• Event-Driven Programming: DynamoDB can trigger AWS Lambda functions in response to data changes using
DynamoDB Streams. This can be used to implement real-time workflows or asynchronously process data changes.
• Consistency Models: DynamoDB supports both eventual consistency and strong consistency. You can choose the
level of consistency you want based on your application’s needs:
• Eventually consistent reads provide lower latency and higher throughput, but the data may be slightly out of
sync for a brief period.
• Strongly consistent reads guarantee that you always get the most up-to-date data, but they can have higher
latency and may reduce throughput.
• Built-in Security: It integrates with AWS Identity and Access Management (IAM) for access control, enabling you to
set granular permissions on who can access data. It also supports encryption at rest and in transit.
• Cost-Effective: DynamoDB uses a pay-per-request pricing model, meaning you only pay for the throughput (read and
write capacity) you use, or you can use on-demand mode to pay based on the actual number of reads and writes
your application performs.
FUNDAMENTALS OF SCALABLE COMPUTING
DynamoDB
• In DynamoDB, tables, items, and attributes are the core components
• A table is a collection of items and each item is a collection of attributes
• DynamoDB uses primary keys to uniquely identify each item in a table and
secondary indexes to provide more querying flexibility
• DynamoDB supports two different kinds of primary keys:
• Partition key – A simple primary key, composed of one attribute known as the
partition key. DynamoDB uses the partition key's value as input to an internal hash
function. The output from the hash function determines the partition (physical
storage internal to DynamoDB) in which the item will be stored.
• Partition key and sort key – Referred to as a composite primary key, this type of key
is composed of two attributes. The first attribute is the partition key and the second
attribute is the sort key. All items with the same partition key value are stored
together in sorted order by sort key value. The Partition Key decides the physical
Location of Data, but the Sort Key then decides the relative logical position of
associated item's record inside that physical location.
FUNDAMENTALS OF SCALABLE COMPUTING
DynamoDB
Secondary Indexes
• Users can create one or more secondary indexes on a table.
• A secondary index lets users query the data in the table using an alternate key, in addition to queries
against the primary key.
• E-commerce Platforms: Storing user profiles, cart items, orders, and transaction logs that need to
be accessed rapidly and scale with user traffic.
• IoT Applications: Storing sensor data or device states, where high write throughput is essential.
• Gaming Backends: Storing user sessions, scores, achievements, and real-time leaderboards.
• Content Management Systems: Storing and retrieving large amounts of unstructured content like
media files, product descriptions, or user-generated content.
FUNDAMENTALS OF SCALABLE COMPUTING
DynamoDB use case
▪ Linux Containers or LXC is an operating-system-level virtualization method for running multiple isolated
Linux systems (containers) which can run multiple workloads, on a control host running a single linux OS
instance
▪ LXC provides a virtual environment that has its own process and network space and does not create a full-
fledged virtual machine.
▪ LXC uses Linux kernel cgroups and namespace isolation functionality to achieve the same.
Motivation
▪ VMs support the objective of virtualizing the physical systems and allowing multiple tenants/applications to
be isolated and share the physical resources along with Access control
▪ One of the challenges as observed is, this isolation achieved by or provided by VM is expensive
▪ Traditional OSs supporting multiple application processes, but share a disk, with all the processes capable
of seeing the entire filesystem with access control built on top, and also share a network.
▪ Containers using a light weight mechanism, provide this virtualization extending the isolation provided by
our traditional OS Lxc (tools) is an user space toolset for creating & managing Linux Containers – different from LXC Linux containers
FUNDAMENTALS OF SCALABLE COMPUTING
What is Containerization?
• Containerization is the packaging of software code with just the operating system (OS) libraries
and dependencies required to run the code to create a single lightweight executable—called a
container that runs consistently on any infrastructure.
• More portable and resource-efficient than virtual machines (VMs), containers have become the de
facto compute units of modern cloud-native applications.
• Containerization allows developers to create and deploy applications faster and more securely.
• Containers are often referred to as “lightweight,” meaning they share the machine’s operating system
kernel and do not require the overhead of associating an operating system within each application.
• Containers are inherently smaller in capacity than a VM and require less start-up time, allowing far
more containers to run on the same compute capacity as a single VM.
FUNDAMENTALS OF SCALABLE COMPUTING
Container Characteristics
▪ Containers sit on top of a physical server and its host OS.
▪ Each container shares the host OS kernel and, usually, the binaries
and libraries too, but as read-only. This reduces the management
overhead where a single OS needs to be maintained for bug fixes,
patches, and so on.
▪ Containers are thus exceptionally “light”—they are only megabytes
in size and take just seconds to start, versus gigabytes and minutes
for a VM.
▪ Container creation is similar to process creation and it has
speed, agility and portability.
▪ Thus containers have higher provisioning performance
FUNDAMENTALS OF SCALABLE COMPUTING
Benefits of Containerization
• Portability: A container creates an executable package of software that is abstracted away from the
host operating system, and hence, is portable and able to run uniformly and consistently across any
platform or cloud.
• Agility: The open source Docker Engine for running containers started the industry standard for
containers with simple developer tools and a universal packaging approach that works on both Linux
and Windows operating systems.
• Speed: Containers are often referred to as “lightweight,” meaning they share the machine’s
operating system (OS) kernel and are not bogged down with this extra overhead
• Fault isolation: Each containerized application is isolated and operates independently of others. The
failure of one container does not affect the continued operation of any other containers
FUNDAMENTALS OF SCALABLE COMPUTING
Benefits of Containerization
• Virtual machines (VMs) are an abstraction of • Containers are an abstraction at the app layer
physical hardware turning one server into that packages code and dependencies together.
many servers. • Multiple containers can run on the same
• The hypervisor allows multiple VMs to run on machine and share the OS kernel with other
a single machine. containers, each running as isolated processes in
• Each VM includes a full copy of an operating user space.
system, the application, necessary binaries
and libraries - taking up tens of GBs.
• VMs can also be slow to boot
FUNDAMENTALS OF SCALABLE COMPUTING
VM vs. Containers
1. Each VM includes a separate OS image, which adds overhead in memory and storage footprint.
Containers reduce management overhead as they share a common OS, only a single OS needs to be
maintained for bug fixes, patches, and so on.
2. In terms of performance, VMs have to boot when provisioned making it slower, and also have I/O
performance overhead
Containers have higher performance as its creation is similar to process creation, so boots quickly and it
has speed, agility and portability
3. VMs are more flexible as Hardware is virtualized to run multiple OS instances.
Containers run on a single OS and also can support only Ubuntu containers of that type of OS where
its running or containers cannot be of different OS variants
4. VMs consume more resources and come up slower than Containers which come up more quickly
and consume fewer resources
FUNDAMENTALS OF SCALABLE COMPUTING
Docker
• Docker is a set of PaaS products that use OS-level virtualization to deliver software in packages called containers.
• Docker isn’t a programming language, and it isn’t a framework for building software.
• Docker is a tool that helps solve common problems such as installing, removing, upgrading, distributing, trusting, and running software.
• Docker is an open source project for building, shipping, and running programs
• Docker containers allow us to separate the applications from the infrastructure enabling faster deployment of applications/software
• It significantly reduces the time between writing code and running it in production by providing methodologies for shipping, testing and
deploying code quickly. Docker provides the isolation and security to allow many containers to run on a single server or virtual machine.
• Docker allows these containers to be shared in a way that it would work identically. Its typical to find between 8 -18 containers running
simultaneously on a single server/VM.
• Docker can be used with network applications such as web servers, databases, and mail servers, and with terminal applications including text
editors, compilers, network analysis tools, and scripts.
• In some cases, it’s even used to run GUI applications such as web browsers and productivity software.
• Docker runs Linux software on most systems.
• Docker for Mac and Docker for Windows integrate with common virtual machine (VM) technology to create portability with Windows
and macOS.
• Docker can run native Windows applications on modern Windows server machines.
FUNDAMENTALS OF SCALABLE COMPUTING
Docker Benefits
Developers use Version Control Systems (VCS) like Git. DevOps also uses VCS for docs, scripts and Dockerfiles.
DevOps could use Dockerfile to describes how to build the image, and something like docker-compose.yml to describe how to orchestrate them.
FUNDAMENTALS OF SCALABLE COMPUTING
Docker Architecture
Reference:https://docs.docker.com/get-started/overview/
FUNDAMENTALS OF SCALABLE COMPUTING
Docker Architecture
Docker Host
▪ Docker Host has the Docker Daemon running and can host (like a private hub/registry) or connect
(like to a public docker_hub/registry) to a Docker Registry which stores the Docker Images.
▪ The Docker Daemon running within Docker Host is responsible for the Docker Objects images and
containers.
Docker Objects :
There are objects like
▪ Images
▪ Containers
▪ Networks
▪ Volumes
▪ Plugins and other objects which are created and used while using docker.
FUNDAMENTALS OF SCALABLE COMPUTING
Docker Objects : Images
Images : This is a read-only template with instructions for creating a Docker container. This could be
based on another image (available in the registry) with additional customizations. Eg. Image for a
Webserver .. Original image of Ubuntu customized with installation and configuration of the
webserver which is created only as a read-only image which can be deployed and an application can
be run in the same.
This is done using a Dockerfile a script file which defines the syntax to indicate steps needed to
create the image (and run using a run command).
Each instruction in a Dockerfile creates a layer in the image.
These Dockerfiles are distributed along with software that the author wants to be put into an image.
In this case, you’re not technically installing an image. Instead, you’re following instructions to build
an image.
FUNDAMENTALS OF SCALABLE COMPUTING
Docker Objects : Images – More on Dockerfile
▪ Distributing a Dockerfile is similar to distributing image files using your own distribution mechanisms. A
common pattern is to distribute a Dockerfile with software from common version-control systems like Git.
• If you have Git installed, you can try this by running an example from a public repository:
o git clone https://github.com/dockerinaction/ch3_dockerfile.git
o docker build -t dia_ch3/dockerfile:latest ch3_dockerfile
In this example, you copy the project from a public source repository onto your computer and then build and
install a Docker image by using the Dockerfile included with that project. The value provided to the -t option
of docker build is the repository where you want to install the image.
▪ Building images from Dockerfile is a light way to move projects around that fits into existing workflows. Could
lead to an unfavorable experience in case of a drift in dependencies between the time when the Dockerfile
was authored and when an image is built on a user’s computer.
▪ Docker Images can be removed or cleaned up with
o docker rmi dia_ch3/dockerfile
o rm -rf ch3_dockerfile Docker Commands – Video Ref: https://www.youtube.com/watch?v=nXV6qihj5uw
FUNDAMENTALS OF SCALABLE COMPUTING
Docker Objects : Images - layers
▪ Docker Containers are the ready applications created from Docker Images.
Or you can say they are running instances of the Images and they hold the
entire package needed to run the application Or it could also be looked at
as a runnable instance of an image Or an execution environment (sandbox).
▪ We can create, start, stop, move, or delete a container using the Docker API or CLI.
▪ A container can be connected to one or more networks. Storage could be attached to it, or even new image
could be created based on its current state.
▪ A container is relatively well isolated from other containers and its host machine and this isolation can also
be controlled. Processes in the container cannot access non-shared objects of other containers, and can only
access a subset of the objects (like files) on the physical machine.
▪ Docker creates a set of name spaces when a container is created. These namespaces restrict what the objects
processes in a container can see e.g. a subset of files
▪ A container is defined by its image and the configuration options provided to it when its created or started.
When a container is removed, any changes to its state that are not stored in persistent storage will disappear
FUNDAMENTALS OF SCALABLE COMPUTING
Docker running three containers on a basic Linux computer system
• A Dockerfile is a script that describes steps for Docker to take to build a new image.
• These files are distributed along with software that the author wants to be put into an image. In this case, you’re not
technically installing an image. Instead, you’re following instructions to build an image.
• Distributing a Dockerfile is similar to distributing image files using your own distribution mechanisms. A common
pattern is to distribute a Dockerfile with software from common version-control systems like Git or Mercurial.
• If you have Git installed, you can try this by running an example from a public repository:
• git clone https://github.com/dockerinaction/ch3_dockerfile.git
• docker build -t dia_ch3/dockerfile:latest ch3_dockerfile
• In this example, you copy the project from a public source repository onto your computer and then build and install a
Docker image by using the Dockerfile included with that project. The value provided to the -t option of docker build is
the repository where you want to install the image.
FUNDAMENTALS OF SCALABLE COMPUTING
Docker namespaces and cgroups
• Namespaces are a feature in the Linux Kernel and fundamental aspect of
containers on Linux.
• Namespaces provide a layer of isolation. Docker uses namespaces of
various kinds to provide the isolation that containers need in order to
remain portable and refrain from affecting the remainder of the host
system. This isolation allows containers to run independently, even though
they share the same operating system kernel.
• Each aspect of a container runs in a separate namespace and its access is
limited to that namespace.
• Cgroups provide resource limitation and reporting capability within the • Common control groups
• CPU
container space. They allow granular control over what host resources are • Memory
• Network Bandwidth
allocated to the containers and when they are allocated. • Disk
• Priority
FUNDAMENTALS OF SCALABLE COMPUTING
Docker used Namespaces
▪ Docker builds containers at runtime using 10 major system features. Docker commands can be
used to illustrate and modify features to suit the needs of the contained software and to fit the
environment where the container will run.
▪ The specific features are as follows (a few of them are discussed in a little more detail):
• PID namespace—Process isolation through identifiers (PID number) – not aware of what
happens outside its own processes
• UTS namespace—allows for having multiple hostnames on a single physical host - Host and
domain name (as other things like IP can change)
• MNT namespace—isolate a set of mount points such that processes in different namespaces
cannot view each others files. (almost like chroot) (Filesystem access & structure)
• IPC namespace—provides isolation to container process communication over shared memory
and having an ability to invite other processes to read from the shared memory
https://www.redhat.com/sysadmin/7-linux-namespaces
FUNDAMENTALS OF SCALABLE COMPUTING
Docker used Namespaces (Cont.)
• NET namespace—allow processes inside each namespace instance to have access to a new
IP address along with the full range of ports - Network access and structure
• USR namespace—provides user name-UID mapping isolating changes in names from the
metadata within a container
• chroot syscall—Controls the location of the filesystem root
• cgroups—Controlling and accounting resources –rather than a hierarchical cgroup creation,
there is a new cgroup with a root directory created to isolate resources and not allow
navigation
• CAP drop—Operating system feature restrictions
• Security modules—Mandatory access controls
https://www.redhat.com/sysadmin/7-linux-namespaces
FUNDAMENTALS OF SCALABLE COMPUTING
Cgroups (or Control groups)
• Cgroup is a linux feature to limit, police, and account the resource usage for a set of processes.
Docker uses cgroups to limit the system resources.
• Cgroups - provides mechanisms (fine grain control) to allocate, monitor and limit resources such
as CPU time, system memory, block IO or disk bandwidth, network bandwidth, or combinations
of these resources — among user-defined groups of tasks (processes) running on a system.
• Cgroups works on resource types. So it works by dividing resources into groups and then assigning
tasks to those groups, deny access to certain resources, and even reconfigure our cgroups
dynamically on a running system.
• When you install Docker binary on a linux box like ubuntu it will install cgroup related packages
and create subsystem directories.
• Hardware resources can be appropriately divided up among tasks and users, increasing overall
efficiency.
FUNDAMENTALS OF SCALABLE COMPUTING
VM vs Docker
1. Docker
2. AWS Fargate
3. Google Kubernetes Engine
4. Amazon ECS
5. LXC
6. Microsoft Azure
7. Google Cloud Platform
8. Core OS
THANK YOU
container.
FUNDAMENTALS OF SCALABLE COMPUTING
Running a program with Docker
• Notice that the command-line interface, or CLI, runs in what is called user space
memory, just like other programs that run on top of the operating system.
• Ideally, programs running in user space can’t modify kernel space memory.
• Broadly speaking, the operating system is the interface between all user programs
and the hardware that the computer is running on.
Fundamentals of Scalable Computing
Distributed systems and Trends - DevOps
• Before DevOps, developing and operating software were essentially two separate jobs, performed by two
different groups of people.
• Developers wrote software, and they passed it on to operations staff, who ran and maintained the software in
production
• Software development was a very specialist job, and so was computer operation, and there was very little
overlap between these two roles
• The two departments had quite different goals and incentives, which often conflicted with each other.
• Developers tended to focus on shipping new features quickly, while operations teams cared mostly about
making services stable and reliable over the long term
• The origins of the DevOps movement lie in attempts to bring these two groups together: to collaborate, to
share understanding, to share responsibility for systems reliability and software correctness, and to improve the
scalability of both the soft- ware systems and the teams of people who build them.
FUNDAMENTALS OF SCALABLE COMPUTING
What does DevOps mean?
• It’s nothing more than a modern label for existing good practice in software development which
fosters greater collaboration between development and operations
• Four key pillars of DevOps - culture, automation, measurement, and sharing (CAMS).
• Organizations practicing DevOps have a culture that embraces collaboration, rejects siloing
knowledge between teams, and comes up with ways of measuring how they can be constantly
improving
• Another way to break it down is called the DevOps trinity: people and culture, process and
practice, and tools and technology.
• The most important thing to understand about DevOps is that it is primarily an organizational,
human issue, not a technical one
FUNDAMENTALS OF SCALABLE COMPUTING
Definition
Operations Org
Development Org
DEV OPS
FUNDAMENTALS OF SCALABLE COMPUTING
Make the balance between Dev & Ops
In pre-cloud era, requires a lot of manual intervention like procuring machines, etc.
§ Faster Time to Market – checkins more often, so can build and test more often.
§ Quality of Code/Release - improved because of frequent testing
§ Integration Often
§ Deploy Often – changes reach the customers often
§ Automated – Repeatable and faster
§ Every one is happy (Hopefully!!)
FUNDAMENTALS OF SCALABLE COMPUTING
Automation : Principles of Continuous Delivery
Principle #1 Principle #3
Every build is a potential release Automate wherever possible
Principle #4
Principle #2 Have automated tests you can trust
Eliminate manual bottlenecks
FUNDAMENTALS OF SCALABLE COMPUTING
Keep it Simple
Typical pipeline for containerized applications might look like the following:
1. A developer pushes his/her code changes to Git.
2. The build system automatically builds the current version of the code and runs some sanity tests.
3. If all tests pass, the container image will be published into the central container registry.
4. The newly built container is deployed automatically to a staging environment.
5. The staging environment undergoes some automated acceptance tests.
6. The verified container image is deployed to production.
FUNDAMENTALS OF SCALABLE COMPUTING
Continuous Integration
Continuous Integration (CI) is the practice of routinely integrating code changes into the main branch of a repository, and
testing the changes, as early and often as possible. Ideally, developers will integrate their code daily, if not multiple times a
day.
Benefits of CI:
• Shorter integration cycles
• Better visibility of what others are doing leading to greater communication
• Issues are caught and resolved early
• Better use of time for development rather than debugging
• Early knowledge that your code works along with others' changes
• Ultimately, enabling the team to release software faster
FUNDAMENTALS OF SCALABLE COMPUTING
Continuous Development
§ This includes continuous code development, continuous integration and continuous Build
§ Developers distributed across geographies
§ Consistent coding style
§ Need to keep the changes in sync
§ Can’t rely on mailing individual changes
§ Everyone needs to have a common view of the code.
§ Continuous integration (CI): the automatic merging of the code, Requires every module to compile
(Build) correctly and then do sanity testing of developers’ changes against the mainline branch.
§ If you’re making changes on a branch that would break the build when merged to the mainline,
continuous integration will let you know that right away, rather than waiting until you finish your
branch and do the final merge.
§ Tool : Source Code Version Management Systems like git, ClearCase, Maven, ANT, Jenkins, Travis CI,
or Drone are often used to automate build pipelines
FUNDAMENTALS OF SCALABLE COMPUTING
Continuous Delivery / Continuous Testing / Continuous Deployment
Continuous delivery is the frequent shipping of sanitized builds to a given environment (such as test or
production) for automatic developments.
§ This could be done using tools like Jenkins the open source Java based application which automates
many parts of the software delivery pipeline
Continuous Testing
§ Continuous testing is the process of executing predominantly automated tests as part of the
software delivery pipeline for validating the code to ensure that the application works as envisaged
and is free of bugs or defects and can be continuously deployed
§ These tests are typically designed to be executed with minimum wait times and provide the earliest
possible feedback & support detection (or prevention) of the risks that are most critical for the
business or organization that is associated with the software release candidate.
(Cont.)
FUNDAMENTALS OF SCALABLE COMPUTING
Continuous Delivery / Continuous Testing / Continuous Deployment
• Continuous Delivery (CD) ensures that every code change is tested and ready for the production
environment, after a successful build.
• CI ensures every code is committed to the main code repository whereas CD ensures the system
is in an executable state at all times, after changes to code
• The primary goal of Continuous Delivery is to make software deployments painless, low-risk
events that can be performed at any time, on demand
• The actual process of automatic deployment in the target customer environment comes under
Continuous Deployment (CD)
• Continuous Delivery can work only if Continuous Integration is in place
FUNDAMENTALS OF SCALABLE COMPUTING
DevOps Tools
FUNDAMENTALS OF SCALABLE COMPUTING
Jenkins
• Jenkins is a very widely adopted CD tool. There is also a newer dedicated side project for running Jenkins in
Kubernetes cluster, JenkinsX.
• Jenkins is a self-contained, open source automation server which can be used to automate all sorts of tasks
related to building, testing, and delivering or deploying software.
• Jenkins can be installed through native system packages, Docker, or even run standalone by any machine with
a Java Runtime Environment (JRE) installed.
• Jenkins is a highly extensible product whose functionality can be extended through the installation of plugins.
• There are a vast array of plugins available to Jenkins.
• Plugins are the primary means of enhancing the functionality of a Jenkins environment to suit organization- or
user-specific needs.
• There are over a thousand different plugins which can be installed on a Jenkins controller and to integrate
various build tools, cloud providers, analysis tools, and much more.
FUNDAMENTALS OF SCALABLE COMPUTING
CI/CD Tools
FUNDAMENTALS OF SCALABLE COMPUTING
DevOps Metrics
• Metrics give insights into what's happening at all stages of the DevOps pipeline, from design to development to
deployment.
• Metrics are objective measures. They strengthen the feedback loops that are essential to DevOps.
• Collecting metrics and displaying them via dashboards or scorecards should be automated.
• It's important to map these metrics to business needs.
FUNDAMENTALS OF SCALABLE COMPUTING
Cloud Native applications
• The term cloud native has become an increasingly popular shorthand way of talking about modern
applications and services that take advantage of the cloud, containers, and orchestration, often
based on open source software
References:
https://www.guru99.com/jenkins-
tutorial.html
https://www.guru99.com/devops-
tutorial.html
• Container orchestrator: a piece of software designed to join together many different machines into
a cluster: a kind of unified compute substrate, which appears to the user as a single very powerful
computer on which containers can run.
• Operations teams, too, find their workload greatly simplified by containers.
• Instead of having to maintain a sprawling estate of machines of various kinds, architectures, and
operating systems, all they have to do is run a container orchestrator
• A third important activity is cluster management: joining multiple physical or virtual servers into a
unified, reliable, fault-tolerant, apparently seamless group.
• The term container orchestrator usually refers to a single service that takes care of scheduling,
orchestration and cluster management.
• Containers providing this computation environment is considered Immutable
• Kubernetes is the most pervasive container orchestration platform to address these challenges.
• Kubernetes is an open-source container management (orchestration) tool.
• It’s container management responsibilities include container deployment, scaling & descaling
of containers & container load balancing.
• It lets you manage complex application deployments quickly in a predictable and reliable
manner.
FUNDAMENTALS OF SCALABLE COMPUTING
Container orchestration (Cont.)
Container Orchestration mediates between the apps/services and the container runtimes
Functional Aspects
• Service Management: Labels (represents
Key-Value pairs that are attached to objects
such as pods and used to specify identifying
attributes of objects), groups (collection of
related functionality), namespaces,
dependencies, load balancing, readiness
checks.
• Scheduling: Allocation, replication,
(container) resurrection, rescheduling, rolling
deployment, upgrades, downgrades.
• Resource Management: Memory, CPU, GPU,
volumes, ports, IPs.
FUNDAMENTALS OF SCALABLE COMPUTING
Container orchestration – Tools
1. Docker Swarm: Provides native clustering functionality for Docker
containers, which turns a group of Docker engines into a single, virtual
Docker engine.
2. Google Container Engine: Google Container Engine, built on Kubernetes,
can run Docker containers on the Google Cloud.
3. Kubernetes: An orchestration system for Docker containers. It handles
scheduling and manages workloads based on user-defined parameters.
4. Amazon ECS: The ECS supports Docker containers and lets you run
applications on a managed cluster of Amazon EC2 instances.
5. Azure Container Service (ACS): ACS lets you create a cluster of
virtual machines that act as container hosts along with master
machines that are used to manage your application containers.
6. Cloud Foundry’s Diego: Container management system that
combines a scheduler, runner, and health manager.
FUNDAMENTALS OF SCALABLE COMPUTING
Kubernetes Basics (K8)
• Containerisation has brought a lot of flexibility for developers in terms of managing the
deployment of the applications.
• More granular application consists of more components and hence requires some sort of
management for those.
• Kubernetes as seen earlier is a container or microservice platform that orchestrates
computing, networking, and storage infrastructure workloads. Kubernetes extends how we
scale containerized applications so that we can enjoy all the benefits of a truly immutable
infrastructure
• Need a solution to
• take care of scheduling the deployment of a certain number of containers to a specific
node
• manage networking between the containers
• follow the resource allocation http://kubernetes.io/docs/concepts/overview/what-is-kubernetes/
• move containers around as they grow and much more.
FUNDAMENTALS OF SCALABLE COMPUTING
Kubernetes Basics (Cont.)
1. Basic Building objects
• Replication of components ▪ Pod. A group of one or more containers.
• Auto-scaling ▪ Service. An abstraction that defines a logical set of pods as well as the policy and an endpoint for
accessing them.
• Load balancing ▪ Volume. An abstraction that lets us persist data. (This is necessary because containers are
ephemeral—meaning data is deleted when the container is deleted.)
• Rolling updates ▪ Namespace. A segment of the cluster dedicated to a certain purpose, for example a certain project or
team of devs. Typically used to create multiple virtual Kubernetes clusters within a single cluster
• Logging across components 2. Controllers which are several higher-level abstractions. Basic K8S objects include -
▪ ReplicaSet (RS). Ensures the desired amount of pod is what’s running.
• Monitoring and health checking ▪ Deployment. Offers declarative updates for pods in an RS.
• Service discovery ▪ StatefulSet. A workload API object that manages stateful applications, such as databases.
▪ DaemonSet. Ensures that all or some worker nodes run a copy of a pod. This is useful for daemon
• Authentication applications like Fluentd.
▪ Job. Creates one or more pods, runs a certain task(s) to completion, then deletes the pod(s)
Kubernetes does the things that the very best system administrator would do: automation, failover,
centralized logging, monitoring. It takes what we’ve learned in the DevOps community and makes it the
default, out of the box.
- Kelsey Hightower, Staff Developer Advocate, Google Cloud Platform at Google .
FUNDAMENTALS OF SCALABLE COMPUTING
Kubernetes Architecture
Pod: container
or group of
containers
Kubernetes targets the management of elastic applications that consist of multiple microservices
communicating with each other. Often those microservices are tightly coupled forming a group of
containers that would typically, in a non-containerized setup run together on one server. This group, the
smallest unit that can be scheduled to be deployed through K8s is called a pod.
The master node is responsible for the management of Kubernetes cluster. This is the entry point of all
administrative tasks. The master node is the one taking care of orchestrating the worker nodes, where the
actual services are running.
FUNDAMENTALS OF SCALABLE COMPUTING
Kubernetes Building blocks - Pod
• Kubernetes targets the management of elastic applications that consist of multiple microservices communicating with
each other.
• Often those microservices are tightly coupled forming a group of containers that would typically, in a non-containerized
setup run together on one server.
• This group, the smallest unit that can be scheduled to be deployed through K8s is called a pod. Pod is a single or group
of containers that share storage and network within a Kubernetes configuration, telling those containers how to
behave.
• Pods share storage, Linux namespaces, cgroups, IP addresses and communicate with each other over localhost
networking
• Each pod is assigned an IP address on which it can be accessed by other pods within a cluster. Applications within a pod
have access to shared volumes – helpful for when you need data to persist beyond the lifetime of a pod.
• They are co-located, hence share resources and are always scheduled together.
• Pods are not intended to live long. They are created, destroyed and re-created on demand, based on the state of the
server and the service itself.
FUNDAMENTALS OF SCALABLE COMPUTING
Kubernetes Building Blocks : Pod (Cont)
▪ A Pod is scheduled or assigned to a node by the scheduler and the kubelet starts creating containers for that
Pod using a container runtime. There are three possible container states: Waiting, Running, and Terminated.
▪ Pods follow a defined lifecycle, starting in the Pending phase, moving through Running if at least one of its
primary containers starts OK, and then through either the Succeeded or Failed phases depending on
whether any container in the Pod terminated in failure.
▪ Pods are only scheduled once in their lifetime. Once a Pod is scheduled (assigned) to a Node, the Pod runs on
that Node until it stops or is terminated
▪ Whilst a Pod is running, the kubelet is able to restart containers to handle some kind of faults. Within a Pod,
Kubernetes tracks different container states and determines what action to take to make the Pod healthy
again.
▪ Volumes exists as long as that specific Pod (with that exact UID) exists unless its an persistent volume for
shared storage between the containers
▪ Pods do not, by themselves, self-heal. If a Pod is scheduled to a node that then fails, the Pod is deleted;
https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/
FUNDAMENTALS OF SCALABLE COMPUTING
Kubernetes - Service
Services is coupling of a set of pods to a policy by which to access them. Services are used to
expose containerized applications to originations from outside the cluster
▪ Pods in a Kubernetes deployment are regularly created and destroyed, causing their IP
addresses to change constantly. It will create discoverability issues for the deployed application,
making it difficult for the application frontend to identify which pods to connect.
▪ To address this K8s introduced the concept of a service, which is an abstraction on top of a
number of pods which has a Virtual IP address assigned to it which is exposed and used by the
service proxies running on top of it.
▪ Other services communicate with the service via this Virtual IP address, and the service keeps
track of the changes in IP addresses and DNS names of the pods and map them to this virtual IP.
▪ A Kubernetes service is a logical collection of pods in a Kubernetes cluster.
▪ This is where we can configure load balancing for our numerous pods and expose them via a
service.
FUNDAMENTALS OF SCALABLE COMPUTING
Kubernetes Components – Master Node
Master Node
API server
etcd storage
controller-manager
Scheduler
FUNDAMENTALS OF SCALABLE COMPUTING
Kubernetes Components – Worker Node
Docker
Kubelet
kube-proxy
Kubectl
FUNDAMENTALS OF SCALABLE COMPUTING
Kubernetes Components – Master Node
Master Node
The master node is responsible for the management of Kubernetes cluster. This is the entry point of all
administrative tasks. The master node is the one taking care of orchestrating the worker nodes, where the
actual services are running.
It exposes the API, schedules deployments, and generally manages the cluster.
Let's dive into each of the components of the master node.
API server (Kube-apiserver)
The API server is the entry points for all the REST commands used to control the cluster. It processes the
REST requests, validates them, and executes the bound business logic. The result state has to be persisted
somewhere (etcd component of the master node).
FUNDAMENTALS OF SCALABLE COMPUTING
Kubernetes Components – Master Node (Cont.)
etcd storage
• etcd is a simple, distributed, consistent key-value stores all cluster data (Can be run on the same
server as a master node or on a dedicated cluster) .
• It’s mainly used for shared configuration and service discovery.
• It provides a REST API for CRUD operations as well as an interface to register watchers on specific
nodes, which enables a reliable way to notify the rest of the cluster about configuration changes.
• CRUD - Create, Read, Update, and Delete, which are four primitive database operations.
• An example of data stored by Kubernetes in etcd is jobs being scheduled, created and deployed,
pod/service details and state, namespaces and replication information, etc.
FUNDAMENTALS OF SCALABLE COMPUTING
Kubernetes Components - Master Node (Cont.)
Kube controller-manager
• Optionally we can run different kinds of controllers inside the master node.
• A controller uses API server to watch the shared state of the cluster and makes corrective changes to the current
state to change it to the desired one.
• An example of such a controller is the Replication controller, which takes care of the number of pods in the system.
The replication factor is configured by the user, and it's the controller’s responsibility to recreate a failed pod or
remove an extra-scheduled one.
• Other examples of controllers are endpoints controller, namespace controller, and service accounts controller.
Kube- Scheduler
• Has information on the resources available. Schedules new pods on worker nodes
• Deploys configured pods and services onto the nodes
• The scheduler has the information regarding resources available on the members of the cluster, as well as the ones
required for the configured service to run and hence is able to decide where to deploy a specific service.
FUNDAMENTALS OF SCALABLE COMPUTING
Kubernetes Components – Worker Node
Worker node
The pods are run here, so the worker node contains all the necessary services to manage the networking
between the containers, communicate with the master node, and assign resources to the containers
scheduled.
Docker
• Docker runs on each of the worker nodes, and runs the configured pods.
• It takes care of downloading the images and starting the containers.
FUNDAMENTALS OF SCALABLE COMPUTING
Kubernetes Components - Worker Node (Cont.)
Kubelet
• kubelet gets the configuration of a pod from the API server and ensures that
the described containers are up and running.
• This is the worker service that’s responsible for communicating with the
master node.
• It also communicates with etcd, to get information about services and write
the details about newly created ones.
FUNDAMENTALS OF SCALABLE COMPUTING
Kubernetes Components - Worker Node (Cont.)
kube-proxy
• kube-proxy acts as a network proxy and a load balancer for a service on a single worker node.
• It takes care of the network routing for TCP and UDP packets.
Kubectl
• A command line tool to communicate with the API service and send commands to the master
node.
• Kubernetes, you will describe the configuration of an application using say a JSON file.
The configuration file tells the configuration management tool where to find the
container images, how to establish a network, and where to store logs.
• When deploying a new container, the container management tool automatically
schedules the deployment to a cluster and finds the right host, taking into account any
defined requirements or restrictions. The orchestration tool then manages the
container’s lifecycle based on the specifications that were determined in the compose
file.
FUNDAMENTALS OF SCALABLE COMPUTING
Kubernetes Benefits
• Horizontal scaling. Scale your application as needed from command line or UI.
• Automated rollouts and rollbacks. Roll out changes in a controlled fashion while monitoring the health of
your application in the container and if something goes wrong, K8S automatically rolls back the change.
• Service discovery and load balancing. Kubernetes can expose a containers using a DNS name or IP and based
on the load, can do load balancing by distribute traffic.
• Storage orchestration. Automatically mount local or public cloud or a network storage.
• Secret and configuration management. Kubernetes lets you store and manage sensitive information, such as
passwords, OAuth tokens, and SSH keys. You can deploy and update secrets and application configuration
without rebuilding your container images, and without exposing secrets in your stack configuration.
• Self-healing. The platform heals many problems: restarting failed containers, replacing and rescheduling
containers as nodes die, killing containers that don’t respond to your user-defined health check, and waiting
to advertise containers to clients until they’re ready.
• Batch execution. Manage your batch and Continuous Integration workloads and replace failed containers.
• Automatic binpacking. Automatically schedules containers based on resource requirements like CPU and
memory which the containers need along with other constraints into the same host
FUNDAMENTALS OF SCALABLE COMPUTING
Docker and Kubernetes – A Brief Comparison
• Docker is a containerization platform, and Kubernetes is a container orchestrator for container platforms like
Docker.
• Docker provided an open standard for packaging and distributing containerized applications while
Kubernetes will coordinate and schedule these containers , seamlessly upgrade an application without any
interruption of service, monitor the health of an application, know when something goes wrong and
seamlessly restart it.
• Docker’s own native clustering solution for Docker containers is Docker Swarm , which has the advantage of
being tightly integrated into the ecosystem of Docker, and uses its own API.
• Like most schedulers, Docker Swarm provides a way to administer a large number of containers spread
across clusters of servers.
• Its filtering and scheduling system enables the selection of optimal nodes in a cluster to deploy
containers. https://www.sumologic.com/blog/kubernetes-vs-docker/
FUNDAMENTALS OF SCALABLE COMPUTING
Docker and Kubernetes – A Brief Comparison (Cont.)
https://www.civo.com/blog/kubernetes-vs-docker-a-comprehensive-comparison
THANK YOU
§ Wait-Free: A slow/failed client will not interfere with the requests of a fast client
FUNDAMENTALS OF SCALABLE COMPUTING
Apache ZooKeeper – What is Apache ZooKeeper
• An open source, high-performance coordination service for distributed applications having many hosts.
• It automates this process of management of the hosts and allows developers to focus on building software
features rather than worry about its distributed nature.
• It provides a Centralized coordination service that can be used by distributed applications to maintain
configuration information, perform distributed locks & synchronization and enable group services.
• It uses a shared hierarchical name space of data registers (called znode’s) to coordinate distributed processes.
• Exposes common services in simple interface:
§ Naming
§ configuration management
§ locks & synchronization
§ group services
.. developers don't have to write them from scratch ..Build your own on it for specific needs.
• For reliability, three copies of the ZooKeeper can be run so that it does not become a single point of failure.
• Apache Kafka uses ZooKeeper to manage configuration, Apache HBase uses ZooKeeper to track the status of
distributed data.
FUNDAMENTALS OF SCALABLE COMPUTING
Apache Zookeeper – How does it work?
• ZooKeeper allows distributed processes to coordinate with each other through a shared hierarchical
namespace which is organized similar to a standard file system
• The namespace consists of data registers - called znodes and these are similar to files and
directories.
• Unlike a typical file system, which is designed for storage, ZooKeeper data is kept in-memory, which
means ZooKeeper can achieve high throughput and low latency numbers.
• Like the distributed processes it coordinates, ZooKeeper itself is intended to be replicated over a set
of hosts called an ensemble.
FUNDAMENTALS OF SCALABLE COMPUTING
Apache Zookeeper – How does it work?
• The servers that make up the ZooKeeper service must all know about each other. They maintain an in-
memory image of state, along with a transaction logs and snapshots in a persistent store.
• As long as a majority of the servers are available, the ZooKeeper service will be available.
• Clients connect to a single ZooKeeper server. The client maintains a TCP connection through which it
sends requests, gets responses, gets watch events, and sends heart beats.
• If the TCP connection to the server breaks, the client will connect to a different server.
• ZooKeeper stamps each update with a number that reflects the order of all ZooKeeper transactions.
Subsequent operations can use the order to implement higher-level abstractions, such as
synchronization primitives.
FUNDAMENTALS OF SCALABLE COMPUTING
Apache ZooKeeper Features
1. Updating the Node’s Status: updates every node that allows it to store updated information about
each node across the cluster.
2. Managing the Cluster: manage the cluster in such a way that the status of each node is maintained
in real time, leaving lesser chances for errors and ambiguity.
3. Naming Service: attaches a unique identification to every node which is quite similar to the DNA
that helps identify it.
4. Automatic Failure Recovery: locks the data while modifying which helps the cluster recover it
automatically if a failure occurs in the database.
FUNDAMENTALS OF SCALABLE COMPUTING
Apache ZooKeeper: Architecture
Server : The server sends an acknowledgement when any client connects. A leader is elected at startup.
All servers store a copy of the data tree (discussed later) in memory
Client: Client is one of the nodes in the distributed application cluster. It helps you to accesses
information from the server. Every client sends a message to the server at regular intervals that helps
the server to know that the client is alive.
In the case when there is no response from the connected server, the client automatically redirects the
message to another server.
FUNDAMENTALS OF SCALABLE COMPUTING
Apache ZooKeeper: Architecture
Leader: One of the servers is designated a Leader. It gives all the information to the clients as well as an
acknowledgment that the server is alive. It would perform automatic recovery if any of the connected
nodes failed.
Follower: Server node which follows leaders instruction is called a follower.
§ Client read requests are handled by the correspondingly connected ZooKeeper server
§ The client writes requests are handled by the ZooKeeper leader.
Ensemble/Cluster: Group of ZooKeeper servers which is called ensemble or a Cluster. You can use
ZooKeeper infrastructure in the cluster mode to have the system at the optimal value when you are
running the Apache.
ZooKeeper WebUI: If you want to work with ZooKeeper resource management, then you need to use
WebUI. It allows working with ZooKeeper using the web user interface, instead of using the command
line. It offers fast and effective communication with the ZooKeeper application.
FUNDAMENTALS OF SCALABLE COMPUTING
Apache ZooKeeper: Data Model
• The data model follows a Hierarchal namespace (like a file system) as discussed earlier
• A node is a system where the cluster runs and each Zookeeper Data Model
Ephemeral nodes:
• These znodes exists as long as the session that created the znode is active. When the session ends the znode is deleted.
Watches:
• ZooKeeper supports the concept of watches. Clients can set a watch on a znode.
• A watch will be triggered and removed when the znode changes.
• When a watch is triggered, the client receives a packet saying that the znode has changed.
• If the connection between the client and one of the ZooKeeper servers is broken, the client will receive a local notification.
Guarantees:
• Sequential Consistency - Updates from a client will be applied in the order that they were sent.
• Atomicity - Updates either succeed or fail. No partial results.
• Single System Image - A client will see the same view of the service regardless of the server that it connects to. i.e., a client will never
see an older view of the system even if the client fails over to a different server with the same session.
• Reliability - Once an update has been applied, it will persist from that time forward until a client overwrites the update.
• Timeliness - The clients view of the system is guaranteed to be up-to-date within a certain time bound.
FUNDAMENTALS OF SCALABLE COMPUTING
Apache ZooKeeper
Each Znode has version number, is incremented every time its data changes
• setData and delete take version as input, operation succeeds only if client’s version is equal to server’s one
FUNDAMENTALS OF SCALABLE COMPUTING
ZooKeeper Reads/Writes/Watches
ZooKeeper Service
Leader
• One of the design goals of ZooKeeper is providing a very simple programming interface.
• As a result, it supports only these operations:
1. create : creates a node at a location in the tree
2. delete : deletes a node
3. exists : tests if a node exists at a location
4. get data : reads the data from a node
5. set data : writes data to a node
6. get children : retrieves a list of children of a node
7. sync : waits for data to be propagated
FUNDAMENTALS OF SCALABLE COMPUTING
Apache Zookeeper – Implementation
• Request Processor
• Atomic Broadcast
• Zab Protocol
• Replicated Database
https://www.tutorialspoint.com/ZooKeeper/ZooKeeper_overview.htm
FUNDAMENTALS OF SCALABLE COMPUTING
Disadvantages of ZooKeeper
● Other solutions like consul have features like service discovery baked in, with health checks in
the loop, while ZooKeeper does not.
● The ephemeral node lifecycle is tied to TCP connection; it can happen that TCP connection is
up, but the process on the other side just went out of memory or otherwise not functioning
properly
● It’s Complex
FUNDAMENTALS OF SCALABLE COMPUTING
When to use Apache Zookeeper
● Naming service - Naming Service is a specific service whose aim is to provide a consistent and uniform naming of
resources, thus allowing other programs or services to localize them and obtain the required metadata for
interacting with them
● Configuration management - store and manage configuration settings of the entire system and its components
● Data Synchronization - Data synchronization is the process of establishing consistency among data from a source
to a target data storage and vice versa and the continuous harmonization of the data over time.
● Leader election - Leader election is the process of designating a single process as the organizer of some task
distributed among several computers.
● Message queue - Typically used for inter-process communication, or for inter-thread communication within the
same process.
● Distributed Locks – Generally used as Globally synchronous locks, which means at any snapshot in time no two
clients think they hold the same lock
FUNDAMENTALS OF SCALABLE COMPUTING
Apache Zookeeper – Use cases
THANK YOU
https://aws.amazon.com/solutions/case-studies/netflix
https://dev.to/gbengelebs/netflix-system-design-backend-architecture-10i3
FUNDAMENTALS OF SCALABLE COMPUTING
Case Study - Netflix
• Netflix uses Amazon's Elastic Load Balancer (ELB) service to route traffic to
services.
• ELB’s are set up such that load is balanced across zones first, then
instances.
• Netflix uses Zuul as its API gateway, It handles all the requests and
performs the dynamic routing of microservice applications. It works as a
front door for all the requests.
• The Cloud Gateway team at Netflix runs and operates more than 80
clusters of Zuul 2, sending traffic to about 100 (and growing) backend
service clusters which amount to more than 1 million requests per second.
FUNDAMENTALS OF SCALABLE COMPUTING
Case Study – Netflix Application API
• Supposing the user clicks on play for the latest episode of peaky
blinders, the request will be routed to the playback API.
• The API in turn calls several microservices under the hood.
• Some of these calls can be made in parallel because they don’t
depend on each other. Others have to be sequenced in a specific
order.
• The API contains all the logic to sequence and parallelize the calls as
necessary.
• The device, in turn, doesn’t need to know anything about the
orchestration that goes on under the hood when the customer clicks
“play”
FUNDAMENTALS OF SCALABLE COMPUTING
Case Study – Netflix Container Management
EVCache
• A cache's primary purpose is to increase data retrieval
performance by reducing the need to access the underlying
slower storage layer
• A cache typically stores a subset of data transiently
• EVCache is a caching solution that is mainly used for AWS EC2
infrastructure for caching frequently used data
EVCache is an abbreviation for:
• Ephemeral - The data stored is for a short duration as specified
by its TTL (Time To Live).
• Volatile - The data can disappear any time (Evicted).
• Cache - An in-memory key-value store.
FUNDAMENTALS OF SCALABLE COMPUTING
Case Study – Netflix Datastores
MySQL
• Netflix uses AWS EC2 instances of MYSQL for its Billing infrastructure.
Billing infrastructure is responsible for managing the billing state of
Netflix members.
• The payment processor needed the ACID capabilities of an RDBMS to
process charge transactions.
Apache Cassandra
• Cassandra is a free and open-source distributed wide column store
NoSQL database designed to handle large amounts of data across many
commodity servers, providing high availability with no single point of
failure.
• Netflix uses Cassandra for its scalability, lack of single points of failure,
and cross-regional deployments.
• Netflix stores all kinds of data across their Cassandra DB instances. All
user collected event metrics are stored on Cassandra.
FUNDAMENTALS OF SCALABLE COMPUTING
Case Study – Netflix Stream Processing
Kafka
• Netflix embraces Apache Kafka® as the de-facto standard for its
eventing, messaging, and stream processing needs. Kafka acts as
a bridge for all point-to-point and Netflix Studio wide
communications.
Apache Chukwe- Analyzing Streaming Data
• Apache Chukwe is an open-source data collection system for
collecting logs or events from a distributed system. It is built on
top of HDFS and Map-reduce framework.
Apache Spark - Analyzing Streaming Data
• Netflix uses Apache Spark and Machine learning for Movie
recommendation
FUNDAMENTALS OF SCALABLE COMPUTING
Case Study – Netflix Stream Processing
FUNDAMENTALS OF SCALABLE COMPUTING
Case Study – Netflix deployed on AWS
Infrastructure services provided by AWS to deliver its content securely and reliably at a massive scale
Netflix uses:
• Amazon Elastic Compute Cloud (Amazon EC2) for computing resources
• Amazon Relational Database Service (Amazon RDS) for database instances
• Amazon Simple Storage Service (Amazon S3) for storage
• Amazon CloudFront for the content delivery network (CDN) bandwidth capacity
• Elastic Load Balancing for load balancing across multiple data center locations
• Auto Scaling Groups for automatically adding or removing servers depending upon fluctuating demand from
customers
• DynamoDB NoSQL database as an alternative choice for highly scalable applications that require rapid access
time without traditional relational database management system (RDBMS) features such as transactions or
referential integrity constraints
FUNDAMENTALS OF SCALABLE COMPUTING
Case Study – Netflix
References:
1. Netflix System Design - https://dev.to/gbengelebs/netflix-system-design-how-netflix-onboards-new-content-2dlb
2. Netflix System Design Backend Architecture - https://dev.to/gbengelebs/netflix-system-design-backend-architecture-
10i3
3. How Netflix is using AWS and its own CDN - https://ayushhsinghh.medium.com/case-study-how-netflix-is-using-aws-
and-its-own-cdn-64ca6282eda0
4. https://www.cloudthat.com/resources/blog/how-netflix-uses-aws-to-deliver-a-personalized-and-interactive-viewing-
experience
5. Netflix Case Study – AWS - https://aws.amazon.com/solutions/case-studies/netflix-case-study/
6. Netflix on AWS - https://aws.amazon.com/solutions/case-studies/innovators/netflix/
7. https://www.linkedin.com/pulse/how-netflix-uses-aws-services-ajinkya-khandave/
8. https://www.linkedin.com/pulse/case-study-netflix-using-aws-cloud-abhinav-singh/
THANK YOU
Dr. Radhika M. Hirannaiah
Department of Computer Science and Engineering
[email protected]