Distributed lock Services in C # and. Net

Source: Internet
Author: User
Tags zookeeper

Background

The distributed lock service may not be used much in everyone's project, because everyone put the exclusive on the database layer to block. When a large number of row locks, table locks, transactions filled with the database, it is better to change the angle of thinking. General Web applications A lot of bottlenecks are in the database, here to introduce you to reduce the database lock burden of a scheme.

Brief introduction

If our requirements are simple, for example, for the user's account funds, to ensure that the atomic operation. and different clients can commit only one object operation at the same time. Lock, single case?! On a single platform can also, but on large Web projects, load balancing is a commonly used technical means, the same meaning objects may have different replicas, then how we guarantee exclusive operations. The transaction of the database! In addition to this, we then draw the topic of this chapter, the Distributed lock service.

A simple lock service is not difficult to implement, and even using memcache can quickly construct a distributed locking system. We only need to be in the operation of the object to write the KV key value pairs, the operation is completed when the release of KV, in the reading of the object to determine whether there is data in kv, we can even give it a default release time.

It's a solution, but if we're asking a little bit higher, we need permission to authenticate (such as only requests from the XXX domain name), the need for a subordinate node association (for example, a user's fund account is locked, while locking his cart, points, etc.), the need for monitor callback, and even consider a single point of failure. So, Bugs here recommend another set of options----zookeeper.

Zookeeper

Official documents: Http://zookeeper.apache.org/doc/r3.3.2/zookeeperOver.html#ch_DesignOverview

Download: http://zookeeper.apache.org/releases.html

Zookeeper is a module in Hadoop. is a distributed, open source distributed Application Coordination service that can be used to synchronize services and configure maintenance.

More content to see the document or directly online search, theoretical content written more people sleepy. We look directly at practice.

Performance Chapter

Server Ubuntu (virtual machine one)

Client window2003

The service side installs the Java environment and follows the official introduction deployment

Start Zkserver

We test the lower lock service-related operations

This article URL address: http://www.bianceng.cn/Programming/csharp/201410/45479.htm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.