Keeping up with our trend to make the Nuxeo Platform better and more powerful, we have introduced some cool features in our latest release, Nuxeo LTS 2015. One of these cool features is that you can now configure the Nuxeo Platform to forward all downloads directly to a cloud blob storage endpoint, such as Amazon S3 or Microsoft Azure. This means that your server will be free during the download and it will be able to handle a lot more download requests, thus scaling you blog download rate significantly!
Today, I’ll show you how you can do that with Microsoft Azure. In my next blog, I’ll talk about how to do the same using your existing S3 install.
Configure the BinaryStore Manager with Azure
You can get a global view of the module configuration and help from the documentation about Microsoft Azure binary manager or documentation about Amazon S3 binary manager.
To start the configuration, let’s use the passwords encryption in your configuration file. It allows you to encrypt any configuration entry in your nuxeo.conf file, and in our case, can hide your access tokens from the bad guys!
Assuming you are currently using a registered Nuxeo instance, here’s what you can do:
# Install Microsoft Azure marketplace package
$ nuxeoctl mp-install microsoft-azure-online-storage
# Add the encrypted value of nuxeo.storage.azure.account.key
$ nuxeoctl config --set --encrypt nuxeo.storage.azure.account.key V3rYUns3Cur3Ent4Y/k3YCryPt3d/NiSamVMdgEqPN+jINb3Bg81Two06LJEtcpM/Oyl1KcuDC7E3/Z==
# And why not doing the same with the account name?
$ nuxeoctl config --set --encrypt nuxeo.storage.azure.account.name Als0Crypt3d0559843256027
# The container name can be in clear text (Do not be too paranoid).
$ nuxeoctl config --set nuxeo.storage.azure.container my-container
Your blobs are now stored in a scalable and very efficient cloud storage engine and your access tokens are secure.
With this configuration, when a user tries to download a blob for the first time:
- the file is downloaded from the cloud storage
- stored in the binary manager local cache for further use
- then returned to the client as quickly as possible
But, we want to achieve a very large number of downloads and we can do much better than this! Let’s see how.
Increase Your Download Rate
Let’s significantly increase the amount of downloads that we can handle by enabling the new direct download feature. With this configuration, when a blob download is requested:
- Nuxeo responds to the client with a redirect to the cloud blob store
- The client downloads the file directly from one of the cloud storage facilities
You might be wondering: What about the security!? I do not want my blobs to be accessed by everyone. Don’t worry, it won’t happen! The request is signed to allow the download on the given URL only for a small amount of time, then you’ll need to get another url.
All you have to do is add these lines to your nuxeo.conf file and you are all set.
# If you are using Azure storage
# Or S3
# You can also change the expiration time of the direct link with (in seconds)
Better and Faster with a Content Delivery Network (CDN)
Here’s something else you might be thinking now: Ok, that’s sounds great. But all my clients are spread across the world and they may get some latency issues depending on the region.
Don’t worry! These main storage systems (S3 and Azure) have already thought about it, and they allow you to easily bind a Content Delivery Network (CDN) to your cloud storage. I will not discuss how CDN works, but to give you an idea, let’s consider this scenario: Assume that previously with the cloud storage your blob was available from one region only (except if you enable S3 Cross-Region replication, or Azure RA-GRS replication). Using a CDN, your content is automatically replicated in several regions and makes your worldwide users very happy.
Here’s how you can configure the Azure CDN.
Configuring Azure CDN
The configuration is really simple. Just follow the documentation on how to integrate a Storage Account with CDN. Then, add these lines in your nuxeo.conf file:
# Ensure direct download is enable
# Then set the cdn host which is binded to your storage
Your download requests will now be redirected to the CDN.
Configuring Your Own Content Delivery Network Strategy
If you prefer to use some other CDN or simply your own Proxy to cache content that needs an url rewrite, that’s fine too. It’s definitely possible. Open your prefered IDE and create a new class that extends:
org.nuxeo.ecm.core.storage.sql.S3BinaryManager or just your own
All you have to do is override the
org.nuxeo.ecm.blob.AbstractCloudBinaryManager#getRemoteUri method like we have done in org.nuxeo.ecm.blob.azure.AzureCDNBinaryManager.
That’s all! Try it out and let us know what you think.