Skip to main content

Posts tagged with 'microsoft'

This is a repost that originally appeared on the Couchbase Blog: Test Drive: Trying Couchbase on Azure for Free.

Test Drive is an Azure feature that allows you to try out software in the cloud for free.

Previously, I wrote about how Getting started with Couchbase on Azure is easy and free. That post told you how to get started with $200 in Azure credit. With Test Drive, however, it’s even easier to get started, and you don’t have to use any of that $200 credit.

Test Drive on Azure Marketplace

The only thing you need before you start is a Microsoft account, which is free.

Create account for free

Couchbase Azure product page

There’s a big "Test Drive" button. Simply click to get started.

Launch test drive

Before you click to get started, notice that the Test Drive has a limited duration. You will get 3 hours to evaluate Couchbase Server.

Step by Step Evaluation Labs

We’ve prepared 4 step-by-step labs that you can follow to start evaluating Couchbase Server.

The test drive deployment is a fully functional Couchbase Server Enterprise cluster with all features enabled. The only limit you have is time.

Summary

Couchbase is proud to partner with Microsoft to make this test drive available to you.

If you are interested in learning more about Couchbase on Azure, please check out these other blog posts:

If you have any questions, comments, or suggestions, please leave a comment, email me [email protected], or tweet me @mgroves on Twitter.

This is a repost that originally appeared on the Couchbase Blog: Scaling Couchbase Server on Azure.

Scaling is one of Couchbase Server’s strengths. It’s easy to scale, and Couchbase’s architecture makes an efficient use of your scaling resources. In fact, when Couchbase customer Viber switched from Mongo to Couchbase, they cut the number of servers they needed in half.

This blog post is the third in a (loose) series of posts on Azure.

The first post showed you the benefits of serverless computing on Azure with Couchbase.

The second post showed a concrete example of creating a chatbot using Azure functions and Couchbase Server.

The previous post only used a cluster with a single node for demonstration purposes. Now suppose you’ve been in production for a while, and your chatbot is starting to get really popular. You need to scale up your Couchbase cluster. If you deployed Couchbase from the Azure Marketplace, this is a piece of cake. Long story short: you pretty much just move a slider. But this post will take you all the way through the details:

  1. Creating a brand new cluster with 3 nodes.

  2. Scaling the cluster up to 5 nodes.

  3. Scaling the cluster down to 4 nodes.

Create Couchbase Cluster on Azure

Assuming you have an Azure account, login to the portal. If you don’t yet, Getting Started with Azure is Easy and Free.

Once you’re logged in, click "+ New" and search for Couchbase Server in the marketplace. I’m using BYOL (bring your own license) for demonstration, but there is also an "Hourly Pricing" option that comes with silver support.

Couchbase in the Azure Marketplace

Once you select Couchbase, you’ll be taken through an Azure installation wizard. Click the "Create" button to get started.

Azure step 0 - create

Step 1 is the "Basics". Fill out the username and password you want for Couchbase, the name of a resource group, and a location (I chose North Central US because it is close to me geographically). Make sure to make a note of this information, as you’ll need it later.

Azure step 1 - basics

The next step is Couchbase Config. There are some recommended VM types to use. I went with DS1_V2 to keep this blog post cheap, but you probably want at least 4 cores and 4gb of RAM for your production environment. I also elected not to install any Sync Gateway Nodes, but if you plan to use Couchbase Mobile, you will need these too. I’m asking for a total of 3 nodes for Couchbase Server.

Azure step 2 - Couchbase Config

After this, step 3 is just a summary of the information you’ve entered.

Azure step 3 - summary

The last step is "buy". This shows you the terms. One "Create" button is all that remains.

Azure step 4 - buy

Now, Azure will go to work provisioning 3 VMs, installing Couchbase Server on them, and then creating a cluster. This will take a little bit of time. You’ll get an Azure notification when it’s done.

Azure provisioning VMs

You should have just enough time to get yourself a nice beverage.

Using your Couchbase Cluster

When Azure finishes with deployment, go look at "Resource groups" in the Azure portal. Find your resource group. Mine was called my_cb_resource_group.

Azure resource groups

Click on the resource group. Inside that resource group, you’ll see 4 things:

  • networksecuritygroups (these are firewall rules, essentially)

  • vnet (the network that all the resources in the group are on)

  • server (Couchbase Server instances)

  • syncgateway (Couchbase Sync Gateway instances. I didn’t ask for any, so this is an empty grouping)

Azure resource group drill down

First, click 'server', and then 'instances'. You should see 3 servers (or however many you provisioned).

Couchbase Servers provisioned

Next, click 'deployments'. You should see one for Couchbase listed. Click it for more information about the deployment.

Azure deployment

The next screen will tell you the URL that you need to get to the Couchbase Server UI (and Sync Gateway UI if you installed that). It should look something like: http://vm0.server-foobarbazqux.northcentralus.cloudapp.azure.com:8091.

Azure deployment info

Paste that URL into a browser. You will be taken to the Couchbase Server login screen. Use the credentials you specified earlier to login.

Couchbase Server login

After you login, click on 'servers'. You will see the three servers listed here. The URLs will match the deployments you see in the Azure portal.

Let’s put some data in this database! Go to Settings → Sample Buckets and load the 'travel-sample' bucket.

Load sample data

This sample data contains 31591 documents. When it’s done loading, go back to "servers". You can see how the 'items' (and replica items) are evenly distributed amongst the three servers. Each node in Couchbase can do both reads and writes, so this is not a master/slave or a read-only replica sets situation.

Couchbase servers

Scaling up

Now, let’s suppose your application is really taking off, and you need to scale up to provide additional capacity, storage, performance. Since we’re using Couchbase deployed from the Azure marketplace, this is even easier than usual. Go to the Azure portal, back to the resource group, and click "server" again. Now click "scaling"

Azure scaling

Next, you will see a slider that you can adjust to add more instances. Let’s bump it up to 5 total servers. Make sure to click "save".

Azure scaling slider

Now, go back to 'instances' again. Note: you may have to refresh the page. Azure doesn’t seem to want to update the stale page served to the browser on its own. You will now see server_3 and server_4 in "creating" status.

Scaling additional servers

You will need to wait for these to be deployed by Azure. In the meantime, you can go back over to the Couchbase Server UI and wait for them to appear there as well.

New Couchbase Server nodes

When adding new servers, the cluster must be rebalanced. The Azure deployment should attempt to do this automatically (but just in case it fails, you can trigger the rebalance manually too).

Couchbase rebalancing

During this rebalance period, the cluster is still accessible from your applications. There will be no downtime. After the rebalance is over, you can see that the # of items on each server has changed. It’s been redistributed (along with replicas).

Cluster after rebalance

That’s it. It’s pretty much just moving a slider and waiting a few minutes.

Scaling Down

At some point, you may want to scale down your cluster. Perhaps you need 5 servers during a certain part of the year, but you only need 3 for other parts, and you’d like to save some money on your Azure bill.

Once again, this is just a matter of adjusting the slider. However, it’s a good idea to scale down one server at a time to avoid any risk of data loss.

Scaling down slider

When you scale down, Azure will pick a VM to decommission. Couchbase Server can respond in one of two ways:

  • Default behavior is to simply indicate that a node is down. This could trigger an email alert. It will show as 'down' in the UI.

  • Auto-failover can be turned on. This means that once a node is down, the Couchbase cluster will automatically consider it 'failed', promote the replicas on other nodes, and rebalance the cluster.

I’m going to leave auto-failover off and show the default behavior.

First, the server will show a status of 'deleting' in the Azure portal.

Scaling down - deleting

Soon after, Couchbase will recognize that a node is not responsive. It will suggest failover to 'activate available replicas'.

Couchbase failing node

I’ll go ahead and do just that.

Manual failover

Once it’s removed from the cluster, you’ll need to trigger a 'rebalance'.

Manual rebalance

Summary and resources

Scaling a Couchbase cluster on Azure is simply a matter of using the slider.

If you’re scaling down, consider doing it one node at a time.

For more information, check out these resources:

If you have questions, please contact me on Twitter @mgroves or leave a comment.

This is a repost that originally appeared on the Couchbase Blog: Azure Functions and Lazy Initialization with Couchbase Server.

Azure Functions are still new to me, and I’m learning as I’m going. I blogged about my foray into Azure Functions with Couchbase over a month ago. Right after I posted that, I got some helpful feedback about the way I was instantiating a Couchbase cluster (and bucket).

I had (wrongly) assumed that there was no way to save state between Azure Function calls. This is why I created a GetCluster() method that was called each time the function ran. But, initializing a Couchbase Cluster object is an expensive operation. The less often you instantiate it, the better.

You can follow along with the updated source code for this blog post on Github.

Static state

I had a hard time finding documentation on whether I could use a static object for reuse between function calls. I suppose I should have experimented, like fellow Microsoft MVP Mark Heath did. Instead, I posed the question to StackOverflow.

In short: yes. A Cluster, instantiated and saved to a static member, can is reusable between function calls. According to Mark’s post above, there’s no guarantee how long this value will survive. But that’s an expected trade-off that you make when going "serverless".

Lazy initializing within Azure Functions

Simply using a static member would work, but it’s not thread-safe. There are a few ways to tackle that issue, but an easy way that’s built right into the .NET framework is to use Lazy Initialization with Lazy<T>.

Lazy Initialization in Azure Functions

First, I removed the GetBucket and GetCluster methods. Next, I created a Lazy<IBucket> property to replace them.

private static readonly Lazy<IBucket> Bucket = new Lazy<IBucket>(() =>
{
    var uri = ConfigurationManager.AppSettings["couchbaseUri"];
    var bucketName = ConfigurationManager.AppSettings["couchbaseBucketName"];
    var bucketPassword = ConfigurationManager.AppSettings["couchbaseBucketPassword"];
    var cluster = new Cluster(new ClientConfiguration
    {
        Servers = new List<Uri> { new Uri(uri) }
    });
    return cluster.OpenBucket(bucketName, bucketPassword);
});

I just made a single property for a bucket, since that’s all I need for this example. But if you need to use the cluster, you can easily make that its own Lazy property. (Once you have a cluster, getting a bucket is a relatively cheap operation).

Using a Lazy property

When you instantiate a Lazy<T> object, you supply it with an initialization lambda. That lambda won’t execute until the Value property is actually called for the first time.

var lazyObject = new Lazy<string>(() =>
{
    // this code won't be called until 'lazyObject.Value' is referenced
    // for the first time
    return "I'm lazy!";
});

For instance, notice the Value between Bucket and GetAsync in the updated version of my Azure Functions:

var doc = await Bucket.Value.GetAsync<MyDocument>(id);

If that’s the first time Value is used, the cluster will be initialized. Otherwise, it will use the already initialized cluster (try experimenting with a Guid instead of a Bucket).

Summary

State can be saved between Azure Function calls by using a static member. Make sure that it’s thread-safe (by using Lazy<T> or something like it). Don’t make any assumptions about how long that object will be around.

Anything else I missed? Are you using Azure Functions with Couchbase? I would love to hear from you. Please leave a comment below or ping me on Twitter @mgroves.

Kevin Groves talks about the movie Pirates of Silicon Valley and the history of personal computing. Note: this is an extra large episode of Cross Cutting Concerns. This is a very broad, historical topic, so it could have easily gone a lot longer!

Show Notes:

I could add a million more links, but instead why don't you leave a comment with your favorite quote, clip, or story about the events that transpired in the movie?

Want to be on the next episode? You can! All you need is the willingness to talk about something technical.

Theme music is "Crosscutting Concerns" by The Dirty Truckers, check out their music on Amazon or iTunes.

Hey, did you know that I'm a Microsoft MVP? As an MVP, sometimes Microsoft lets me do some cool stuff.

Microsoft MVP logo

For instance, they let me write some blog posts about Couchbase with Windows and .NET for the MVP Award Program Blog! There are three total parts, and part 1 was just published.

So go check it out, subscribe to the MVP Award Blog, and most importantly, download Couchbase and try it out today.

I always want to thank fellow MVP Travis Smith for being the technical editor for these posts! He provided some great feedback, and he's an overall great guy!

Matthew D. Groves

About the Author

Matthew D. Groves lives in Central Ohio. He works remotely, loves to code, and is a Microsoft MVP.

Latest Comments

Twitter