Blockchain and Kubernetes For Better Smart Contracts
We are excited to announce improvements to the Dragonchain Smart Contract as a Service (SCaaS) system and our implementation of Kubernetes to solve some of the pain points experienced with AWS Lambda and CloudFormation. These changes include a simplified deployment pipeline and new management tools for users (including contract delete, a widely requested feature). As a result of these improvements, there are a few differences to building and deploying smart contracts on Dragonchain. We hope this post will clarify why we made these changes and how it will affect users and their contracts.
Pain Points with AWS Lambda and CloudFormation
In the previous iteration of the SCaaS system, we used AWS Lambda and CloudFormation to deploy smart contract logic. There were advantages to this approach, notably the ability to use a single stack to represent an entire Dragonchain including contracts and custom behaviors. There were pain points as well, but at the time, the system worked well. As Dragonchain continued to grow and collect community feedback, there were some common observations we gathered from users:
The slow nature of CloudFormation caused contract creation and updates to take up to ten minutes to complete
AWS Lambda limited the languages available to users
Contract deployments and updates could not happen in parallel. This forced all contract operations into a serial pipeline that further slowed development
Logs were inconsistently displayed to the user
CloudFormation made it prohibitively difficult to delete contracts and their stored data. Deleting network interfaces alone could take over an hour
CloudFormation has a limit on resources, which put a hard limit on the number of contracts available to a chain
Lambdas inside VPCs have long warm up times (sometimes up to 10 seconds) and are limited to 350 concurrent executions
Users were frustrated by these limitations and we wanted to help. It quickly became apparent that our system at the time couldn’t scale to match these community expectations, so we went back to the drawing board to build an entirely new SCaaS system. Our goal was to fix these problems without sacrificing functionality our users had grown to expect from Dragonchain.
Advantages of our Blockchain Platform on Kubernetes
In the past, we had seen significant performance and resilience gains by changing Dragonchain to run in Docker containers instead of as a single application. Containers allowed for better separation of concerns, faster deployment, higher reliability, and led to lower response times than we could achieve with Lambda as the backbone of our service. We were also able to use containers in combination with a reverse proxy to avoid limits from API gateway or other similar products. However, running Docker without orchestration software required “babysitting” to ensure that containers could still communicate with each other from their virtual servers. We started looking for a solution that was resilient, scalable, and automated for Dragonchain. We settled on Kubernetes due to its self-healing features, ability to run multiple services on one server, and its large and thriving development community.
Because we were using Kubernetes, we had options when choosing a function as a service (FaaS) framework to use in our SCaaS system. We chose OpenFaaS, an open source library that allows users to package smart contracts as Docker images for easy deployment. Without CloudFormation and AWS Lambda, deployments are noticeably faster and multiple contract operations can run simultaneously. Contract deployment time is now bounded only by the size of the Docker image being deployed, but remains fast even for reasonably large images. We also take advantage of Docker’s flexibility and its ability to support any language that can run on x86 architecture. Any image, public or private, can be run as a smart contract using Dragonchain (yes, you can turn cowsay into a smart contract).
A Better Smart Contracts as a Service System
At Dragonchain, we strive for continuous improvement and rely on our community to let us know what they want to see on the platform. While the SCaaS system we built on AWS Lambdas, using CloudFormation was workable, it had weaknesses that we wanted to improve on. With Docker containers and Kubernetes, we were able to take advantage of OpenFaaS’ excellent documentation and community to rebuild our SCaaS service from the ground up. Because of these technologies, we’re happy to release a faster, more extensible, and easier to use SCaaS system.
Dragonchain is committed to creating developer-friendly interfaces for blockchain technologies. Allowing developers to build smart contracts as docker images in their programming or scripting language of choice is just another step we’ve taken to make blockchain more accessible to users, alongside our open source SDKs. We will continue to reduce the barrier to entry so that “All Humans Are Welcome.” To read more about our SDKs and other resources for building on Dragonchain, check out our Developer Toolkit.