SlideShare une entreprise Scribd logo
1  sur  28
Télécharger pour lire hors ligne
CloudStack Locking
Service
Abhishek Kumar
Software Developer, ShapeBlue
abhishek.kumar@shapeblue.com
About me
 Software Developer at ShapeBlue
 From Meerut, India
 Previously used to develop applications for desktops and mobile
 Worked on CloudStack features – Domain, zone specific offerings, VM
ingestion, container service plugin
 Love going gym, watching action-thriller movies, discussing politics
Objective
New locking service, manager and pluggable
interface with ZooKeeper (using curator
framework), Hazelcast or other distributed lock
managers.
Outcome: cloudstack db can be HA enabled with
multi-master read/write, using clustering
solution.
Peer discovery
Why?
 CloudStack can control 100s of hosts with 1000s of virtual machines
 Can support multiple management servers
 But for database!!!
 Limited support for replication and high availability. Cannot use mult-
master replication
 Implementing active-active, active-passive configuration becomes
difficult
 Database clustering not possible
Topics
 Locking Introduction
 Database locking
 Locking in CloudStack and its limitations
 Distributed locks
 Introduction
 Different Distributed Lock Managers
 Overview of Apache Zookeeper
 Overview of Hazelcast
 Demo
 Implementation of new locking service, pluggable interface with Apache Zookeeper-
Curator, Hazelcast
 Comparison, current limitation, future work
 Q & A
Lock
 Lock or mutex is a synchronization
mechanism for enforcing limits on access to a
resource in an environment where there are
many threads of execution. A lock is designed
to enforce a mutual exclusion concurrency
control policy
 Locks – usually threads of same process,
Mutex – threads from different processes
 Can be advisory or manadatory
 Granularity - measure of the amount of data
the lock is protecting. Fine for smaller,
specific data and coarse for larger data
 Issues –
 Overhead
 Contention
 Deadlock
Database locks
Ensuring transaction synchronicity
 Mainly two types,
 Pessimistic – Record is locked until the lock is released
 Optimistic – System keeps copy of initial read and later verifies data on release
accepting or rejecting update
Wikipedia uses optimistic locking for document editing
 Different granularity
 Database level
 File level
 Table level
 Page or block level
 Row level
 Column level
DB Locks Issues – Lock contention
Many sessions requiring frequent access to same lock for short amount of time resulting
in “single lane bridge”
Example: Deploying 100s of VM simultaneously
DB Locks Issues – Long Term Blocking
Many sessions requiring frequent access to same lock for long period of time resulting in
blocking of all dependent sessions
DB Locks Issues – Database Deadlocks
Occurs when two or
more transactions
hold dependent
locks and neither
can continue until
the other releases
DB Locks Issues – contd.
Other issues,
 Overhead
 Difficult to debug
 Priority inversion
 Convoying
Locking in CloudStack
 Uses MySQL lock functions to acquire and release locks on database
connections
 A hashmap is kept for all the acquired locks and their connection in the code
 Fast and effective as locking is taking place in database itself.
Locking in CloudStack – contd.
Limitations with current design,
 Cannot work with MySQL clustering solutions
This is due to locking functions – GET_LOCK(), RELEASE_LOCK() are not supported by
clustering solutions like Percona XtraDB, https://www.percona.com/doc/percona-
xtradb-cluster/LATEST/limitation.html
 HA enabled, multi-master DB cannot be implemented
Solution could be implementing distributed locks using available distributed
locking services
Distributed Locks
 Synchronize accesses to shared resources for the applications distributed
across a cluster on multiple machines
 Coordination between different nodes
 Ensure only one server can write to a database or write to a file.
 Ensure that only one server can perform a particular action.
 Ensure that there is a single master that processes all writes
Distributed Locking - Implementation
 Complex compared to conventional OS or relational DB locking as more
variables present, network, different nodes which could individually fail at
any time
 Different algorithms – Redis, Paxos, etc.
 Implementation of Distributed Locking Manager (DLM)
 Different types of lock DLM can grant,
Null, Concurrent Read, Concurrent Write, Protected Read, Protected Write, Exclusive
Distributed Locking - Implementation
Null (NL)
Concurrent Read (CR)
Concurrent Write (CW)
Protected Read (PR)
Protected Write (PW)
Exclusive (EX)
Distributed Locking Manager
 Apache ZooKeeper – high performance
coordination service for distributed
systems, can be used for distributed
locks
 Redis - advanced key-value cache and
store, can be used to implement Redis
algorithm for distributed lock
management.
 Hazelcast - distributed In-Memory Data
Grid platform for Java
 Chubby - lock service for loosely
coupled distributed systems developed
by Google
 Etcd, Consul
Apache ZooKeeper
 An open source, high-performance coordination service for distributed
applications.
 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.
 Apache Curator – Java client library
Apache ZooKeeper contd.
• ZooKeeper Service is replicated over a set of machines
• All machines store a copy of the data (in memory)
• A leader is elected on service startup
• Clients only connect to a single ZooKeeper server &
maintains a TCP connection.
• Client can read from any Zookeeper server, writes go
through the leader & needs majority consensus.
Apache ZooKeeper Implementation
Need to use Curator framework with it. Different implementation recipes
available, https://github.com/apache/zookeeper/tree/master/zookeeper-recipes
 Start an embedded server, create client to connect to this server,
File dir = new File(tempDirectory, "zookeeper").getAbsoluteFile();
zooKeeperServer = new ZooKeeperServer(dir, dir, tickTime);
serverFactory = new NIOServerCnxnFactory();
serverFactory.configure(new InetSocketAddress(clientPort), numConnections);
serverFactory.startup(zooKeeperServer);
…
RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
curatorClient = CuratorFrameworkFactory.newClient(String.format("127.0.0.1:%d", clientPort), retryPolicy);
curatorClient.start();
 Locks can be acquired and released for a given name
InterProcessMutex lock = new InterProcessMutex(curatorClient, String.format("%s%s", tempDirectory, name));
lock.acquire(timeoutSeconds, TimeUnit.SECONDS)
…
lock.release();
Hazelcast
 The Hazelcast IMDG operational in-memory computing
platform helps leading companies worldwide manage their
data and distribute processing using in-memory storage
and parallel execution for breakthrough application speed
and scale.
 Hazelcast implement a distributed version of some Java
data structures like Maps, Set, Lists, Queue and Lock
 ILock is the distributed implementation of
java.util.concurrent.locks.Lock.
Hazelcast - Implementation
 Define config, set CPSubsytem member, create HazelcastInstance objects
Config config = new Config();
CPSubsystemConfig cpSubsystemConfig = config.getCPSubsystemConfig();
cpSubsystemConfig.setCPMemberCount(3);
hazelcastInstance = Hazelcast.newHazelcastInstance(config);
...
 Locks can be acquired and released
FencedLock lock = hazelcastInstance.getCPSubsystem().getLock(name);
lock.tryLock(timeoutSeconds, TimeUnit.SECONDS);
...
lock.unlock();
Locking Service in CloudStack
 Pluggable service implementation using
existing distributed lock managers for
different locking service plugins
 Global setting to control the locking
service, db.locking.service.plugin
 Current implementation using Apache
ZooKeeper and Hazelcast
Demo
Why generic framework design
 Choice
 Easier to develop
 Performance difference
Locking Service in CloudStack - Issues
 Apart from traditional issues wrt locking service, speed will be a major issue
compared to existing database locking in CloudStack. Since locking will be
managed by a server it will create an additional overhead
0
2
4
6
8
10
12
Lock 1 Lock 2 Lock 3 Lock 4 Lock 5 Lock 6 Lock 7 Lock 8 Lock 9 Lock
10
Lock
11
Lock
12
Lock
13
Lock
14
Lock
15
Timeinmilliseconds
Locks
Lock acquire performance during VM deployment
Current DB Locking ZooKeeper Hazelcast
Future work
 Current state – basic implementation with HazelCast, ZooKeeper
 Testing with database clustering
 Optimization for better performance
 Implement peer discovery for getting rid of mshost table and using locking
service for discovering different management server nodes.
 Code cleanup and start PR
 Target 4.15(if not 4.14)
Thank You!
Thoughts and Question

Contenu connexe

Tendances

Paris Cassandra Meetup - Overview of New Cassandra Drivers
Paris Cassandra Meetup - Overview of New Cassandra DriversParis Cassandra Meetup - Overview of New Cassandra Drivers
Paris Cassandra Meetup - Overview of New Cassandra Drivers
Michaël Figuière
 
Caching principles-solutions
Caching principles-solutionsCaching principles-solutions
Caching principles-solutions
pmanvi
 
OSDC 2015: Bernd Mathiske | Why the Datacenter Needs an Operating System
OSDC 2015: Bernd Mathiske | Why the Datacenter Needs an Operating SystemOSDC 2015: Bernd Mathiske | Why the Datacenter Needs an Operating System
OSDC 2015: Bernd Mathiske | Why the Datacenter Needs an Operating System
NETWAYS
 
NYC* Tech Day - New Cassandra Drivers in Depth
NYC* Tech Day - New Cassandra Drivers in DepthNYC* Tech Day - New Cassandra Drivers in Depth
NYC* Tech Day - New Cassandra Drivers in Depth
Michaël Figuière
 
SQL Server Cluster Presentation
SQL Server Cluster PresentationSQL Server Cluster Presentation
SQL Server Cluster Presentation
webhostingguy
 

Tendances (20)

Paris Cassandra Meetup - Overview of New Cassandra Drivers
Paris Cassandra Meetup - Overview of New Cassandra DriversParis Cassandra Meetup - Overview of New Cassandra Drivers
Paris Cassandra Meetup - Overview of New Cassandra Drivers
 
Openstack Icehouse IaaS Presentation
Openstack Icehouse  IaaS PresentationOpenstack Icehouse  IaaS Presentation
Openstack Icehouse IaaS Presentation
 
Clustering and High Availability
Clustering and High Availability Clustering and High Availability
Clustering and High Availability
 
DataStax | Best Practices for Securing DataStax Enterprise (Matt Kennedy) | C...
DataStax | Best Practices for Securing DataStax Enterprise (Matt Kennedy) | C...DataStax | Best Practices for Securing DataStax Enterprise (Matt Kennedy) | C...
DataStax | Best Practices for Securing DataStax Enterprise (Matt Kennedy) | C...
 
AppFabric Velocity
AppFabric VelocityAppFabric Velocity
AppFabric Velocity
 
EclipseCon - Building an IDE for Apache Cassandra
EclipseCon - Building an IDE for Apache CassandraEclipseCon - Building an IDE for Apache Cassandra
EclipseCon - Building an IDE for Apache Cassandra
 
Caching principles-solutions
Caching principles-solutionsCaching principles-solutions
Caching principles-solutions
 
Apache Cassandra @Geneva JUG 2013.02.26
Apache Cassandra @Geneva JUG 2013.02.26Apache Cassandra @Geneva JUG 2013.02.26
Apache Cassandra @Geneva JUG 2013.02.26
 
DataStax | Data Science with DataStax Enterprise (Brian Hess) | Cassandra Sum...
DataStax | Data Science with DataStax Enterprise (Brian Hess) | Cassandra Sum...DataStax | Data Science with DataStax Enterprise (Brian Hess) | Cassandra Sum...
DataStax | Data Science with DataStax Enterprise (Brian Hess) | Cassandra Sum...
 
No sql exploration keyvaluestore
No sql exploration   keyvaluestoreNo sql exploration   keyvaluestore
No sql exploration keyvaluestore
 
"Clouds on the Horizon Get Ready for Drizzle" by David Axmark @ eLiberatica 2009
"Clouds on the Horizon Get Ready for Drizzle" by David Axmark @ eLiberatica 2009"Clouds on the Horizon Get Ready for Drizzle" by David Axmark @ eLiberatica 2009
"Clouds on the Horizon Get Ready for Drizzle" by David Axmark @ eLiberatica 2009
 
OSDC 2015: Bernd Mathiske | Why the Datacenter Needs an Operating System
OSDC 2015: Bernd Mathiske | Why the Datacenter Needs an Operating SystemOSDC 2015: Bernd Mathiske | Why the Datacenter Needs an Operating System
OSDC 2015: Bernd Mathiske | Why the Datacenter Needs an Operating System
 
Hazelcast
HazelcastHazelcast
Hazelcast
 
Cassandra 101
Cassandra 101Cassandra 101
Cassandra 101
 
Introduction to failover clustering with sql server
Introduction to failover clustering with sql serverIntroduction to failover clustering with sql server
Introduction to failover clustering with sql server
 
Apache Cassandra at the Geek2Geek Berlin
Apache Cassandra at the Geek2Geek BerlinApache Cassandra at the Geek2Geek Berlin
Apache Cassandra at the Geek2Geek Berlin
 
Compare Clustering Methods for MS SQL Server
Compare Clustering Methods for MS SQL ServerCompare Clustering Methods for MS SQL Server
Compare Clustering Methods for MS SQL Server
 
Gateway Service For NetWare
Gateway Service For NetWareGateway Service For NetWare
Gateway Service For NetWare
 
NYC* Tech Day - New Cassandra Drivers in Depth
NYC* Tech Day - New Cassandra Drivers in DepthNYC* Tech Day - New Cassandra Drivers in Depth
NYC* Tech Day - New Cassandra Drivers in Depth
 
SQL Server Cluster Presentation
SQL Server Cluster PresentationSQL Server Cluster Presentation
SQL Server Cluster Presentation
 

Similaire à Abhishek Kumar - CloudStack Locking Service

Similaire à Abhishek Kumar - CloudStack Locking Service (20)

Containerized Data Persistence on Mesos
Containerized Data Persistence on MesosContainerized Data Persistence on Mesos
Containerized Data Persistence on Mesos
 
Making Distributed Data Persistent Services Elastic (Without Losing All Your ...
Making Distributed Data Persistent Services Elastic (Without Losing All Your ...Making Distributed Data Persistent Services Elastic (Without Losing All Your ...
Making Distributed Data Persistent Services Elastic (Without Losing All Your ...
 
Silicon Valley CloudStack User Group - Introduction to Apache CloudStack
Silicon Valley CloudStack User Group - Introduction to Apache CloudStackSilicon Valley CloudStack User Group - Introduction to Apache CloudStack
Silicon Valley CloudStack User Group - Introduction to Apache CloudStack
 
JCConf 2016 - Cloud Computing Applications - Hazelcast, Spark and Ignite
JCConf 2016 - Cloud Computing Applications - Hazelcast, Spark and IgniteJCConf 2016 - Cloud Computing Applications - Hazelcast, Spark and Ignite
JCConf 2016 - Cloud Computing Applications - Hazelcast, Spark and Ignite
 
Shopzilla On Concurrency
Shopzilla On ConcurrencyShopzilla On Concurrency
Shopzilla On Concurrency
 
Case Study _Cloud Native Transformation Deploying Integration workloads to AK...
Case Study _Cloud Native Transformation Deploying Integration workloads to AK...Case Study _Cloud Native Transformation Deploying Integration workloads to AK...
Case Study _Cloud Native Transformation Deploying Integration workloads to AK...
 
Making Distributed Data Persistent Services Elastic (Without Losing All Your ...
Making Distributed Data Persistent Services Elastic (Without Losing All Your ...Making Distributed Data Persistent Services Elastic (Without Losing All Your ...
Making Distributed Data Persistent Services Elastic (Without Losing All Your ...
 
Horizontal scaling with Galaxy
Horizontal scaling with GalaxyHorizontal scaling with Galaxy
Horizontal scaling with Galaxy
 
Jclouds Intro
Jclouds IntroJclouds Intro
Jclouds Intro
 
Eucalyptus: Open Source for Cloud Computing
Eucalyptus: Open Source for Cloud ComputingEucalyptus: Open Source for Cloud Computing
Eucalyptus: Open Source for Cloud Computing
 
cluster computing
cluster computingcluster computing
cluster computing
 
SMACK Stack 1.1
SMACK Stack 1.1SMACK Stack 1.1
SMACK Stack 1.1
 
Workshop - Openstack, Cloud Computing, Virtualization
Workshop - Openstack, Cloud Computing, VirtualizationWorkshop - Openstack, Cloud Computing, Virtualization
Workshop - Openstack, Cloud Computing, Virtualization
 
Openstack workshop @ Kalasalingam
Openstack workshop @ KalasalingamOpenstack workshop @ Kalasalingam
Openstack workshop @ Kalasalingam
 
Getting Started with Apache CloudStack
Getting Started with Apache CloudStackGetting Started with Apache CloudStack
Getting Started with Apache CloudStack
 
Making Apache Kafka Elastic with Apache Mesos
Making Apache Kafka Elastic with Apache MesosMaking Apache Kafka Elastic with Apache Mesos
Making Apache Kafka Elastic with Apache Mesos
 
As34269277
As34269277As34269277
As34269277
 
Introduction to docker security
Introduction to docker securityIntroduction to docker security
Introduction to docker security
 
Shopzilla On Concurrency
Shopzilla On ConcurrencyShopzilla On Concurrency
Shopzilla On Concurrency
 
Containers and workload security an overview
Containers and workload security an overview Containers and workload security an overview
Containers and workload security an overview
 

Plus de ShapeBlue

Plus de ShapeBlue (20)

CloudStack Authentication Methods – Harikrishna Patnala, ShapeBlue
CloudStack Authentication Methods – Harikrishna Patnala, ShapeBlueCloudStack Authentication Methods – Harikrishna Patnala, ShapeBlue
CloudStack Authentication Methods – Harikrishna Patnala, ShapeBlue
 
CloudStack Tooling Ecosystem – Kiran Chavala, ShapeBlue
CloudStack Tooling Ecosystem – Kiran Chavala, ShapeBlueCloudStack Tooling Ecosystem – Kiran Chavala, ShapeBlue
CloudStack Tooling Ecosystem – Kiran Chavala, ShapeBlue
 
Elevating Cloud Infrastructure with Object Storage, DRS, VM Scheduling, and D...
Elevating Cloud Infrastructure with Object Storage, DRS, VM Scheduling, and D...Elevating Cloud Infrastructure with Object Storage, DRS, VM Scheduling, and D...
Elevating Cloud Infrastructure with Object Storage, DRS, VM Scheduling, and D...
 
VM Migration from VMware to CloudStack and KVM – Suresh Anaparti, ShapeBlue
VM Migration from VMware to CloudStack and KVM – Suresh Anaparti, ShapeBlueVM Migration from VMware to CloudStack and KVM – Suresh Anaparti, ShapeBlue
VM Migration from VMware to CloudStack and KVM – Suresh Anaparti, ShapeBlue
 
How We Grew Up with CloudStack and its Journey – Dilip Singh, DataHub
How We Grew Up with CloudStack and its Journey – Dilip Singh, DataHubHow We Grew Up with CloudStack and its Journey – Dilip Singh, DataHub
How We Grew Up with CloudStack and its Journey – Dilip Singh, DataHub
 
What’s New in CloudStack 4.19, Abhishek Kumar, Release Manager Apache CloudSt...
What’s New in CloudStack 4.19, Abhishek Kumar, Release Manager Apache CloudSt...What’s New in CloudStack 4.19, Abhishek Kumar, Release Manager Apache CloudSt...
What’s New in CloudStack 4.19, Abhishek Kumar, Release Manager Apache CloudSt...
 
CloudStack 101: The Best Way to Build Your Private Cloud – Rohit Yadav, VP Ap...
CloudStack 101: The Best Way to Build Your Private Cloud – Rohit Yadav, VP Ap...CloudStack 101: The Best Way to Build Your Private Cloud – Rohit Yadav, VP Ap...
CloudStack 101: The Best Way to Build Your Private Cloud – Rohit Yadav, VP Ap...
 
How We Use CloudStack to Provide Managed Hosting - Swen Brüseke - proIO
How We Use CloudStack to Provide Managed Hosting - Swen Brüseke - proIOHow We Use CloudStack to Provide Managed Hosting - Swen Brüseke - proIO
How We Use CloudStack to Provide Managed Hosting - Swen Brüseke - proIO
 
Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And...
Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And...Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And...
Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And...
 
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...
 
KVM Security Groups Under the Hood - Wido den Hollander - Your.Online
KVM Security Groups Under the Hood - Wido den Hollander - Your.OnlineKVM Security Groups Under the Hood - Wido den Hollander - Your.Online
KVM Security Groups Under the Hood - Wido den Hollander - Your.Online
 
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...
 
Use Existing Assets to Build a Powerful In-house Cloud Solution - Magali Perv...
Use Existing Assets to Build a Powerful In-house Cloud Solution - Magali Perv...Use Existing Assets to Build a Powerful In-house Cloud Solution - Magali Perv...
Use Existing Assets to Build a Powerful In-house Cloud Solution - Magali Perv...
 
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...
 
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...
 
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
 
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlueElevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
 
Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit...
Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit...Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit...
Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit...
 
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...
 
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlueWhat’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Dernier (20)

HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 

Abhishek Kumar - CloudStack Locking Service

  • 1. CloudStack Locking Service Abhishek Kumar Software Developer, ShapeBlue abhishek.kumar@shapeblue.com
  • 2. About me  Software Developer at ShapeBlue  From Meerut, India  Previously used to develop applications for desktops and mobile  Worked on CloudStack features – Domain, zone specific offerings, VM ingestion, container service plugin  Love going gym, watching action-thriller movies, discussing politics
  • 3. Objective New locking service, manager and pluggable interface with ZooKeeper (using curator framework), Hazelcast or other distributed lock managers. Outcome: cloudstack db can be HA enabled with multi-master read/write, using clustering solution. Peer discovery
  • 4. Why?  CloudStack can control 100s of hosts with 1000s of virtual machines  Can support multiple management servers  But for database!!!  Limited support for replication and high availability. Cannot use mult- master replication  Implementing active-active, active-passive configuration becomes difficult  Database clustering not possible
  • 5. Topics  Locking Introduction  Database locking  Locking in CloudStack and its limitations  Distributed locks  Introduction  Different Distributed Lock Managers  Overview of Apache Zookeeper  Overview of Hazelcast  Demo  Implementation of new locking service, pluggable interface with Apache Zookeeper- Curator, Hazelcast  Comparison, current limitation, future work  Q & A
  • 6. Lock  Lock or mutex is a synchronization mechanism for enforcing limits on access to a resource in an environment where there are many threads of execution. A lock is designed to enforce a mutual exclusion concurrency control policy  Locks – usually threads of same process, Mutex – threads from different processes  Can be advisory or manadatory  Granularity - measure of the amount of data the lock is protecting. Fine for smaller, specific data and coarse for larger data  Issues –  Overhead  Contention  Deadlock
  • 7. Database locks Ensuring transaction synchronicity  Mainly two types,  Pessimistic – Record is locked until the lock is released  Optimistic – System keeps copy of initial read and later verifies data on release accepting or rejecting update Wikipedia uses optimistic locking for document editing  Different granularity  Database level  File level  Table level  Page or block level  Row level  Column level
  • 8. DB Locks Issues – Lock contention Many sessions requiring frequent access to same lock for short amount of time resulting in “single lane bridge” Example: Deploying 100s of VM simultaneously
  • 9. DB Locks Issues – Long Term Blocking Many sessions requiring frequent access to same lock for long period of time resulting in blocking of all dependent sessions
  • 10. DB Locks Issues – Database Deadlocks Occurs when two or more transactions hold dependent locks and neither can continue until the other releases
  • 11. DB Locks Issues – contd. Other issues,  Overhead  Difficult to debug  Priority inversion  Convoying
  • 12. Locking in CloudStack  Uses MySQL lock functions to acquire and release locks on database connections  A hashmap is kept for all the acquired locks and their connection in the code  Fast and effective as locking is taking place in database itself.
  • 13. Locking in CloudStack – contd. Limitations with current design,  Cannot work with MySQL clustering solutions This is due to locking functions – GET_LOCK(), RELEASE_LOCK() are not supported by clustering solutions like Percona XtraDB, https://www.percona.com/doc/percona- xtradb-cluster/LATEST/limitation.html  HA enabled, multi-master DB cannot be implemented Solution could be implementing distributed locks using available distributed locking services
  • 14. Distributed Locks  Synchronize accesses to shared resources for the applications distributed across a cluster on multiple machines  Coordination between different nodes  Ensure only one server can write to a database or write to a file.  Ensure that only one server can perform a particular action.  Ensure that there is a single master that processes all writes
  • 15. Distributed Locking - Implementation  Complex compared to conventional OS or relational DB locking as more variables present, network, different nodes which could individually fail at any time  Different algorithms – Redis, Paxos, etc.  Implementation of Distributed Locking Manager (DLM)  Different types of lock DLM can grant, Null, Concurrent Read, Concurrent Write, Protected Read, Protected Write, Exclusive
  • 16. Distributed Locking - Implementation Null (NL) Concurrent Read (CR) Concurrent Write (CW) Protected Read (PR) Protected Write (PW) Exclusive (EX)
  • 17. Distributed Locking Manager  Apache ZooKeeper – high performance coordination service for distributed systems, can be used for distributed locks  Redis - advanced key-value cache and store, can be used to implement Redis algorithm for distributed lock management.  Hazelcast - distributed In-Memory Data Grid platform for Java  Chubby - lock service for loosely coupled distributed systems developed by Google  Etcd, Consul
  • 18. Apache ZooKeeper  An open source, high-performance coordination service for distributed applications.  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.  Apache Curator – Java client library
  • 19. Apache ZooKeeper contd. • ZooKeeper Service is replicated over a set of machines • All machines store a copy of the data (in memory) • A leader is elected on service startup • Clients only connect to a single ZooKeeper server & maintains a TCP connection. • Client can read from any Zookeeper server, writes go through the leader & needs majority consensus.
  • 20. Apache ZooKeeper Implementation Need to use Curator framework with it. Different implementation recipes available, https://github.com/apache/zookeeper/tree/master/zookeeper-recipes  Start an embedded server, create client to connect to this server, File dir = new File(tempDirectory, "zookeeper").getAbsoluteFile(); zooKeeperServer = new ZooKeeperServer(dir, dir, tickTime); serverFactory = new NIOServerCnxnFactory(); serverFactory.configure(new InetSocketAddress(clientPort), numConnections); serverFactory.startup(zooKeeperServer); … RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3); curatorClient = CuratorFrameworkFactory.newClient(String.format("127.0.0.1:%d", clientPort), retryPolicy); curatorClient.start();  Locks can be acquired and released for a given name InterProcessMutex lock = new InterProcessMutex(curatorClient, String.format("%s%s", tempDirectory, name)); lock.acquire(timeoutSeconds, TimeUnit.SECONDS) … lock.release();
  • 21. Hazelcast  The Hazelcast IMDG operational in-memory computing platform helps leading companies worldwide manage their data and distribute processing using in-memory storage and parallel execution for breakthrough application speed and scale.  Hazelcast implement a distributed version of some Java data structures like Maps, Set, Lists, Queue and Lock  ILock is the distributed implementation of java.util.concurrent.locks.Lock.
  • 22. Hazelcast - Implementation  Define config, set CPSubsytem member, create HazelcastInstance objects Config config = new Config(); CPSubsystemConfig cpSubsystemConfig = config.getCPSubsystemConfig(); cpSubsystemConfig.setCPMemberCount(3); hazelcastInstance = Hazelcast.newHazelcastInstance(config); ...  Locks can be acquired and released FencedLock lock = hazelcastInstance.getCPSubsystem().getLock(name); lock.tryLock(timeoutSeconds, TimeUnit.SECONDS); ... lock.unlock();
  • 23. Locking Service in CloudStack  Pluggable service implementation using existing distributed lock managers for different locking service plugins  Global setting to control the locking service, db.locking.service.plugin  Current implementation using Apache ZooKeeper and Hazelcast
  • 24. Demo
  • 25. Why generic framework design  Choice  Easier to develop  Performance difference
  • 26. Locking Service in CloudStack - Issues  Apart from traditional issues wrt locking service, speed will be a major issue compared to existing database locking in CloudStack. Since locking will be managed by a server it will create an additional overhead 0 2 4 6 8 10 12 Lock 1 Lock 2 Lock 3 Lock 4 Lock 5 Lock 6 Lock 7 Lock 8 Lock 9 Lock 10 Lock 11 Lock 12 Lock 13 Lock 14 Lock 15 Timeinmilliseconds Locks Lock acquire performance during VM deployment Current DB Locking ZooKeeper Hazelcast
  • 27. Future work  Current state – basic implementation with HazelCast, ZooKeeper  Testing with database clustering  Optimization for better performance  Implement peer discovery for getting rid of mshost table and using locking service for discovering different management server nodes.  Code cleanup and start PR  Target 4.15(if not 4.14)