Question

How to deploy Next.js app with multiple Spaces

I’m interested in having additional Spaces to serve my app’s assets to improve redundancy in the event of outage. I’m already looking into syncing the buckets using rClone, but I’m unsure how to have multiple Spaces with my next.js app. With next.js I specify an assetPrefix path to my Spaces CDN.

Is there a straight-forward way of having buckets across multiple regions for a single next.js application on the app platform? How exactly does the CDN work when a Spaces bucket goes down?


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
October 16, 2023
Accepted Answer

Hello,

DigitalOcean’s built-in Spaces CDN inherently has a redundancy mechanism. If a particular CDN edge server faces issues, the system is designed to pull content from the nearest available edge server. Furthermore, in the rare event a Space (the origin) experiences downtime, the CDN will continue to serve cached assets until that cache period elapses.

It’s important to note that the assetPrefix feature in Next.js is not designed to accommodate multiple endpoints out of the box. This limitation is consistent across various service providers, not just DigitalOcean.

While it’s feasible to use a load balancer or a DNS service to switch requests between Spaces based on availability, implementing such a system introduces additional complexity. It’s worth considering if the benefits of this intricate setup outweigh the convenience and reliability of the inherent redundancy provided by the CDN.

That said, employing a secondary Spaces bucket as a backup and synchronizing with rClone is an excellent strategy for ensuring your assets are backed up, which is always a recommended practice.

Hope that this is helpful!

Best,

Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel