[openstack-dev] [Neutron] db-level locks, non-blocking algorithms, active/active DB clusters and IPAM

Salvatore Orlando sorlando at nicira.com
Wed Feb 25 15:39:48 UTC 2015


Thanks Clint.

I think you are bringing an interesting and disruptive perspective into
this discussion.
Disruptive because one thing that has not been considered so far in this
thread is that perhaps we don't need at all to leverage multi-master
capabilities for write operations.

More comments inline,
Salvatore

On 25 February 2015 at 14:40, Clint Byrum <clint at fewbar.com> wrote:

> Excerpts from Salvatore Orlando's message of 2015-02-23 04:07:38 -0800:
> > Lazy-Stacker summary:
> > I am doing some work on Neutron IPAM code for IP Allocation, and I need
> to
> > found whether it's better to use db locking queries (SELECT ... FOR
> UPDATE)
> > or some sort of non-blocking algorithm.
> > Some measures suggest that for this specific problem db-level locking is
> > more efficient even when using multi-master DB clusters, which kind of
> > counters recent findings by other contributors [2]... but also backs
> those
> > from others [7].
> >
>
> Thanks Salvatore, the story and data you produced is quite interesting.
>
> >
> > With the test on the Galera cluster I was expecting a terrible slowdown
> in
> > A-1 because of deadlocks caused by certification failures. I was
> extremely
> > disappointed that the slowdown I measured however does not make any of
> the
> > other algorithms a viable alternative.
> > On the Galera cluster I did not run extensive collections for A-2. Indeed
> > primary key violations seem to triggers db deadlock because of failed
> write
> > set certification too (but I have not yet tested this).
> > I run tests with 10 threads on each node, for a total of 30 workers. Some
> > results are available at [15]. There was indeed a slow down in A-1 (about
> > 20%), whereas A-3 performance stayed pretty much constant. Regardless,
> A-1
> > was still at least 3 times faster than A-3.
> > As A-3's queries are mostly select (about 75% of them) use of caches
> might
> > make it a lot faster; also the algorithm is probably inefficient and can
> be
> > optimised in several areas. Still, I suspect it can be made faster than
> > A-1. At this stage I am leaning towards adoption db-level-locks with
> > retries for Neutron's IPAM. However, since I never trust myself, I wonder
> > if there is something important that I'm neglecting and will hit me down
> > the road.
> >
>
> The thing is, nobody should actually be running blindly with writes
> being sprayed out to all nodes in a Galera cluster. So A-1 won't slow
> down _at all_ if you just use Galera as an ACTIVE/PASSIVE write master.
> It won't scale any worse for writes, since all writes go to all nodes
> anyway.


If writes are sent to a singe node, obviously there will be no contention
at all.
I think Mike in some other thread mentioned the intention of supporting
this scheme as part of the db facade work he's doing.
On the other hand, as you say in this way you'll be effectively using the
DB cluster as ACTIVE/PASSIVE w.r.t writes.
If the fact that there won't be any performance or scalability penalty is
proven, then I think I have no concern about adopting this model. Note that
I'm not saying this because I don't trust you, but merely because of my
ignorance - I understand that in principle what you say is correct, but
since galera replicates through write sets and simply by replying
transaction logs, things might be not as obvious, and perhaps I'd look at
some data supporting this claim.


> For reads we can very easily start to identify hot-spot reads
> that can be sent to all nodes and are tolerant of a few seconds latency.
>

A few second latency sound rather bad, but obviously we need to put
everything into the right context.
Indeed it seems to me that by "hot-spot" you mean reads which are performed
fairly often?
In your opinion, what would be the caveats in always distributing reads to
all nodes?


>
> > In the medium term, there are a few things we might consider for
> Neutron's
> > "built-in IPAM".
> > 1) Move the allocation logic out of the driver, thus making IPAM an
> > independent service. The API workers will then communicate with the IPAM
> > service through a message bus, where IP allocation requests will be
> > "naturally serialized"
>
> This would rely on said message bus guaranteeing ordered delivery. That
> is going to scale far worse, and be more complicated to maintain, than
> Galera with a few retries on failover.
>

I suspect this as well, but on the other hand I believe some components
adopted by several OpenStack projects adopt exactly this pattern. I have
however no data point to make any sort of claim regarding their scalability.
>From an architectural perspective you can make things better by scaling out
the RPC server with multiple workers, but then you'd be again at the
starting point!
When I propose stuff on the mailing list I typically do full brain dumps,
even the terrible ideas, which are unfortunately occur to me very
frequently.


>
> > 2) Use 3-party software as dogpile, zookeeper but even memcached to
> > implement distributed coordination. I have nothing against it, and I
> reckon
> > Neutron can only benefit for it (in case you're considering of arguing
> that
> > "it does not scale", please also provide solid arguments to support your
> > claim!). Nevertheless, I do believe API request processing should proceed
> > undisturbed as much as possible. If processing an API requests requires
> > distributed coordination among several components then it probably means
> > that an asynchronous paradigm is more suitable for that API request.
> >
>
> If we all decide that having a load balancer sending all writes and
> reads to one Galera node is not acceptable for some reason, then we
> should consider a distributed locking method that might scale better,
> like ZK/etcd or the like. But I think just figuring out why we want to
> send all writes and reads to all nodes is a better short/medium term
> goal.
>

I think I agree on this point - meaning that I believe at some we need to
make an architectural decision regarding whether we want to let distributed
coordination to the app layer, or rely on a centralised data source where
serialisation can be enforce through transaction properties and constructs
such as write intent locks. This discussion alone maybe deserves its own
mailing list thread, cross-project spec and summit session. Therefore it
might be better to refrain going into this rabbit hole in this thread.
Looking at the current architecture of several openstack API servers, and
in particular the Neutron API server, I feel that leveraging db-level
constructs at this stage might be the safest approach from scalability,
reliability and maintainability perspectives.


> __________________________________________________________________________
> OpenStack Development Mailing List (not for usage questions)
> Unsubscribe: OpenStack-dev-request at lists.openstack.org?subject:unsubscribe
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20150225/c21c7ed2/attachment.html>


More information about the OpenStack-dev mailing list