Inside Sketch: What happens when you save a document to your Cloud Workspace

You probably work on Sketch documents stored in your Cloud Workspace multiple times a day. But what happens when you actually hit Save? In this article, we’ll dig a little deeper into why we developed our render farm, and how it manages the heavy lifting when it comes to uploading your document to the cloud.

Last year we set out to improve the way in which we uploaded documents to your Cloud Workspace and make the process faster and more efficient for everyone. We also thought about how we could offer new features — like developer handoff and real-time collaboration. Our solution was to build our own render farm.

Wait, did you say “render farm”?

Yes, you read that right. For the last twelve months, we’ve been using a render farm to process your documents so that they’re ready for viewing, inspecting, and asset export in the web app.

Prior to that, whenever you uploaded a document to a Workspace, the Mac app would first need to render every page, Artboard, and Symbol Source (at 1x and 2x) on your computer. The Mac app would then hash all these images and start uploading them to the web app, so you could view your document in the browser. As you can imagine, uploading your document and a bunch of images every time you hit Save was not a fast process.

For this reason (and many others, which we’ll explore more below), we wanted to take the responsibility of rendering previews of your Sketch document away from the Mac app. The answer was a render farm — a collection of servers that receive your document, process it, and generate the previews you see in the web app, as quickly as possible.

But building a render farm for Sketch wasn’t straightforward. Our rendering engine is built on top of Apple’s technologies, which means it needs to run on macOS servers. Plus, in order to perform effectively, we needed to build an orchestrated system that could render hundreds of documents in parallel.

Why build a render farm?

The very first iteration of Sketch for the web was built to simply help you share your documents with others via a link. However, this was just a starting point. Our real goal was to improve collaboration across Sketch. And to do that, we needed Sketch documents to truly live on the server. This wouldn’t just take the rendering workload off your Mac — it would help the browser understand Sketch documents on a deep level.

This was an important goal for us, and it has allowed us to develop some exciting features. The first was developer handoff in the browser, which gives developers ability to inspect any part of the design, as well as the option to download precisely the assets they need — including flattened Symbols. Now, there’s no need for them to open a Sketch file to figure out how it was built up.

None of this would’ve been possible without the render farm. But these were just the first steps. Ultimately, we wanted to do truly innovative things with Sketch documents on the server — things like real-time collaboration in our native Mac app. And to do it, our server-side systems needed a ‘Sketch brain’.

Building a render farm with Sketch smarts

We wanted our render

Continue reading

This post was originally published on this site