Skip to main content
Blog

Moving eSignature to Azure Meant Sharding its Database First

Author Josh Meier
Josh MeierSenior Principal Engineer
•

Summary•15 min read

Our eSignature database had grown to more than 300TB across five sites, and adding hardware had stopped helping. We decided to move to Azure, where adding a shard is a deployment instead of a hardware purchase. This is Part 1 of a two-part series on that migration, covering why we made the move and the engineering work that came before the first cutover.

Part 1 of 2: Why we migrated eSignature to Azure, and the engineering work that came before the first cutover.

- Docusign's eSignature platform processes envelopes, the unit of a signature transaction, for nearly 200 million accounts across five global production sites. When we started planning its migration to Azure, we hit a problem before the migration had properly begun. Azure didn't offer a SQL Server configuration that could hold our database, so Microsoft built one for us. Even with that custom SKU in hand, the database was still too large to move in the shape it was in. We needed a new plan.

eSignature has been our core product for two decades and is one of the oldest parts of our stack. The company was founded in 2003, well before cloud infrastructure existed at enterprise scale, and until recently eSignature ran almost entirely on infrastructure we owned and operated ourselves.

This is the first of a two-part series. In this post we cover why we made the move and the engineering work we had to finish before a single customer account could be touched. Part 2 covers execution: how we cut over five global production sites, live, with the platform running the whole time.

Why we moved eSignature to Azure

The pressure to move was technical first. Cost mattered, and I'll come back to it, but it isn't what set the timeline.

The Docusign Database holds envelopes, accounts, users, and most of eSign's operational state. By the time we started planning in earnest it had grown to a 300TB+ footprint across five sites, making it one of the largest Microsoft SQL Server deployments in the world.

DSDB, short for Docusign Database, is the SQL Server instance at the center of eSignature, with one instance at each site. It holds envelopes, accounts, users, and most of eSign's operational state. By the time we started planning in earnest it had grown to a 300TB+ footprint across five sites, making it one of the largest Microsoft SQL Server deployments in the world.

For most of those two decades our answer to growth was a bigger machine. More cores, more memory, faster storage, a new generation of hardware every few years. That worked well enough that we had no particular reason to revisit it.

The single-node ceiling

Eventually a bigger machine stopped helping. The symptom was latching. Latches are the internal synchronization primitives the engine uses to protect in-memory structures like buffer pages, as distinct from the locks that protect your logical data. When thousands of concurrent workers contend for the same hot pages, they stop doing work and start queuing behind each other. The unpleasant part is that throwing more cores at the problem can make it worse, because now you have more workers contending for the same structures. At our largest site we were watching this happen in real time, and no amount of tuning was going to change the shape of the curve.

Disk, CPU, and memory all had headroom. The database engine itself was the limit.

We did the tuning work anyway, and it mattered. Index changes, query rewrites, moving some read workloads off the instance entirely. All of it bought us quarters rather than years. By that point we were tuning to hold steady rather than to grow, which is how we landed on an architectural fix: DSDB had to be decomposed, and the highest-volume data in it had to be sharded horizontally. That conclusion had nothing to do with Azure; we would have reached it either way.

Why we couldn't do it on-prem

Sharding is an operating model more than a one-time split of a database into N pieces, and it assumes you can add a shard when one gets hot. That assumption is the part we couldn't satisfy on-prem.

In our own data centers, a new shard is a purchase order. It's rack space, power, network, a hardware lead time measured in months, and a capacity forecast you have to commit to roughly a year ahead of when the load actually shows up. Supply chain conditions over the last several years made those lead times both longer and considerably less predictable. So we would have been building an architecture around a promise we couldn't keep: add capacity when you need it.

You can shard on-prem, and plenty of companies have. What it requires is sizing the shard count for the worst case you can imagine a year or two out, buying all of it up front, and then living with whatever you guessed. Guess low and you're back in a contention problem with a procurement cycle in front of you. Guess high and you've spent capital on hardware that sits idle.

In Azure, standing up a new shard is a deployment, so capacity tracks load rather than a forecast made a year earlier.

Geography, newer infrastructure, and cost

Sharding was the forcing function but not the only reason. Geographic reach mattered too. Our customers increasingly want their data processed and stored inside a specific country rather than a specific region, and that trend shows no sign of reversing. Operating a data center in every country we sell into is not a business we want to be in. Cloud regions make in-country presence a project measured in months instead of years.

We also wanted access to newer infrastructure primitives. Managed data services, Kubernetes, elastic capacity for test environments, modern identity and secrets handling. On-prem, each one means standing up a team and funding it indefinitely to maintain something that isn't our product.

And yes, there was cost pressure. Licensing and managed hosting for the on-prem fleet is real money, and decommissioning those facilities is a meaningful line item.

This is the part of cloud migration stories that gets oversold. We did not do this because public cloud is automatically cheaper. It usually isn't, at least not if you move an enterprise application without changing it. The bill goes up. What we were paying for was the ability to change the architecture, and most of the savings sit in work we haven't finished.

What we ruled out before we started

A few things came off the table early. No application rewrite. We stayed on SQL Server, left the customer experience and the API contract alone, and ruled out a single big-bang failover.

The rewrite was the tempting one, but it would also still be in progress, with the database sitting at its ceiling the whole time. So we modernized the database architecture underneath an application that didn't change, and moved traffic in increments as each piece got validated.

What we're betting on

What we expect out of the move: elastic capacity, shard counts that follow contention instead of procurement cycles, faster expansion into new countries, and an exit from the on-prem footprint. Some of that is already true. The rest isn't proven.

We kept the application unchanged on purpose. A 1:1 move would have carried the same scalability limits into Azure, so we decomposed the database first and left everything above it alone. That foundation makes the next phase possible: moving eSign services onto our Kubernetes-based platform, where much of the operational and cost upside sits. We’ll write about that once there’s something to report.

Four problems we had to solve

Executing that meant solving four problems, roughly in this order:

  1. DSDB itself, which was too large and too loaded to move to Azure as-is, even with a custom SKU built for us.

  2. Keeping production live: nearly 200 million accounts, very little tolerance for downtime, and migration happening in flight.

  3. Fifteen years of assumptions baked into the code, mostly cross-table joins that had to move up into the application layer.

  4. Storage, which was its own project, because a key-value store our engineers wrote in-house before cloud-native options existed also had to migrate live.

Why DSDB couldn't move to Azure as it was

DSDB was the right architectural decision when it was built. A single relational database made sense at the time, and as the business grew the database grew with it. Cross-table joins at the SQL level became standard practice across thousands of stored procedures, because everything shared a schema and joining at the database level was fast. That held up for fifteen years, until we needed to move the database somewhere else.

Two things made moving DSDB to Azure as-is a non-starter. It was too large for any standard Azure SQL SKU, and even with the custom SKU Microsoft built for us, the IOPS load DSDB was generating had to come down before a failover could be considered safe.

Splitting DSDB with vertical and envelope sharding

The first step was vertical sharding: pulling discrete functional domains out of DSDB and giving each one its own standalone database. Things like blob metadata, address books, brands, and templates. None of that data needed to be colocated with envelopes. It had simply always been there. Each domain got its own database and connection configuration, and the services that used it were updated to point at the new location. After vertical sharding, DSDB held primarily envelope data alongside user and account data.

Envelope data was the obvious candidate for horizontal sharding, and the harder one to move. Individual envelopes have no dependencies on each other, unlike user and account data, which has to stay colocated. So we built EnvelopeDB, or EVDB, as a horizontally sharded database in Azure.

New envelopes for accounts that have been ramped onto the sharded architecture are created directly in EVDB. Anything already in progress at the time of migration finishes out in DSDB and archives from there. Completed envelopes are rarely revisited, so as the population of open envelopes on DSDB drains, load moves onto EVDB without anyone having to migrate historical data. DSDB's role narrows to user and account data.

Fig. 1: DSDB before and after decomposition. Before, every service queries one instance and joins happen in SQL. After, functional domains move to their own databases, envelope data lives in EVDB, and joins run in the data access layer.

Search needed its own answer. EnvelopeSearchDB, or ESDB, gives the application a consolidated search view across DSDB and the EVDB shards. It runs on Azure SQL Database Hyperscale, so storage, compute, and read replicas scale independently of the transactional path.

We looked at account-based sharding first. Traffic is uneven across accounts, so sharding by account would have concentrated too much load onto a small number of shards and produced hot partitions that wouldn't scale, which would have put us right back into the contention problem we were trying to get out of. Sharding by envelope distributes load evenly no matter which accounts are generating it.

Routing a request to the correct shard needed a mechanism that wouldn't become a bottleneck of its own. We considered a lookup table mapping envelope IDs to shards and rejected that too. A central mapping table is a single point of failure, and at our volume it would grow without bound. Instead we encode the shard ID directly into the envelope GUID using UUID version 8, which permits custom byte formatting. The full mechanics are in Part 2, since it's as much an execution detail as a design one. Any service holding the GUID already knows which shard to query, and no external lookup is required.

Fig. 2: Shard routing. The data access layer reads the version field in the envelope GUID. Version 4 identifiers predate the migration and route to DSDB. Version 8 identifiers carry their shard number in two bytes. No lookup service is involved.

Why moving accounts one at a time failed

Early on we tested an account-by-account migration: move one account's data to Azure, switch its traffic over, repeat. We built it and validated it in lower environments before ruling it out.

The blocker was DSDB. It couldn't run active-active between on-prem and Azure, and an account migrated to Azure still needed to read its user and account data from DSDB, which had to stay on-prem until every account on a given site had moved. That meant every migrated account would be making cross-datacenter calls on every single request, for as long as the migration stayed in progress. We measured the latency impact in staging, confirmed it was a non-starter, and pivoted to a database-level failover instead. All accounts on a site move together, once load reduction and validation criteria are met.

How we kept eSignature live during the migration

Across nearly 200 million eSignature accounts on five production sites, the migration had to be invisible to the overwhelming majority of customers. The target was less than 15 minutes of planned interruption.

Two phases were involved, and we ran them one after the other. Phase 1 moved a site to Azure. Phase 2 moved that site onto the sharded architecture. We kept them from overlapping.

Phase 1 was the site failover, and it was pure DSDB. The database moved to Azure with its shape unchanged: same schema, same instance model, just running somewhere else.

We could only do that because the vertical sharding work, combined with a round of query optimization, had already pulled DSDB's IOPS under the threshold that was blocking the move in the first place. All accounts on a site fail over together, so there was no customer-by-customer ordering to manage once a site's window opened. Part 2 covers the site order and the runbook itself in detail.

Phase 2 was the ramp onto the sharded architecture, which began once a site's stability and performance in Azure had been validated and we were satisfied that a fallback path was no longer warranted. Internal test accounts went first, then free accounts. After that, low-traffic accounts before high-traffic ones, then our larger customers in ascending order of size. The highest-volume accounts moved last. Traffic moved in steps of 10% and 20%, with validation at each step before we went further.

Doing it in that order cost us time and preserved that fallback for as long as it was useful. A site that had failed over but hadn't yet started creating envelopes in EVDB could still go back, because nothing existed in Azure that didn't also exist behind us. Once envelope creation starts on a shard, that option closes.

DSDB and EVDB both run on Azure today. DSDB's role narrowed but it didn't end, and we have no plans to decommission it.

Every new code path shipped behind a feature flag, and the old path stayed untouched until the new one had been validated. Any scenario we hadn't covered in testing would only surface once real accounts depended on the new path.

Routing during the migration window is handled through a unified namespace that automatically directs traffic to whichever Availability Group, on-prem or Azure, is currently primary. Any service still pointed directly at the old on-prem Availability Group name had to be migrated onto that namespace before its traffic could safely fail over. We found a few of those the hard way in lower environments, which is exactly where you want to find them.

Refactoring fifteen years of cross-table joins

Once DSDB was split into separate databases, fifteen years of cross-table join assumptions had to be unwound. Our engineers had written queries that joined envelope data with user data at the SQL level, because both tables had always lived in the same database and joining there was fast. Once those tables moved apart, every one of those joins had to move up into the application layer.

That refactoring touched roughly 500 stored procedures and a corresponding set of service files. It was tedious, and it carried more risk than anything else in the program, because a stored procedure that silently returns slightly wrong data is much worse than one that fails outright.

Validating that we hadn't missed a scenario before real accounts moved took more than 35,000 test cases, run through our internal test automation framework.

Migrating blob storage and Sauce live

Storage goes back to decisions made long before Azure was an option. Two systems matter here, and we built both of them ourselves before cloud-native options existed at the scale and latency we needed. Blob storage holds the document content itself, the PDFs and images that make up an envelope. Sauce is Docusign’s proprietary key-value store that holds the smaller, high-volume data the application reaches for constantly. Between them they carry most of what a signing session actually touches.

Both had to migrate, and neither could go down while it happened.

Sauce was the more interesting of the two. In Azure it becomes a facade over Cosmos DB: same interface to every caller, different storage underneath, and no caller code had to change. Whoever drew that interface boundary was not thinking about a cloud migration. It's the reason we could swap the storage engine without touching anything above it.

Replication did need new engineering. Cosmos DB at the time couldn't do global replication at our scale, so the storage team built a global replicator on top of it.

A one-time bulk copy of either system was never an option, because the migration itself was phased. Five sites moved at different times over a period of months, and in-flight envelopes were reading and writing on both sides of that window. On-prem and Azure had to stay in continuous sync the whole time, so we ran live-live replication for the duration and built a verifier to compare the two sides for correctness rather than assume it.

Before any SQL failover could happen, the blob migration and the Sauce replication layer both had to be fully live in Azure.

Fig. 3: The Sauce interface with two implementations behind it. Callers never knew which one they were talking to. Live-live replication kept both sides consistent while sites moved, and the global replicator covered a gap Cosmos DB couldn't at our scale.

What's next

Part 2 covers the cutover itself: a 40-step runbook the team rehearsed more than 50 times, how shard routing works using only the envelope’s ID, and how five sites went live with zero production rollbacks.

Author Josh Meier
Josh MeierSenior Principal Engineer

Josh Meier is a Senior Principal Engineer at Docusign, where he drives the company’s overall cloud strategy, including its multi-cloud infrastructure platform, customer migration, and the foundation that supports Docusign’s AI capabilities. Before Docusign, he spent more than 12 years at Salesforce, where he was a founding member of the Hyperforce team and later its Principal Software Architect and Product Manager, taking Salesforce from on-premises data centers to public cloud in 20 countries. His career started in quality engineering at Amazon and a startup he co-founded.

More posts from this author

Related posts

  • Engineering

    Turning a Loose Field Definition Into a Reliable Contract Extraction

    Author Docusign AI Team
    Docusign AI Team

Docusign IAM is the agreement platform your business needs

Start for FreeExplore Docusign IAM
Person smiling while presenting