Migration strategies for large-scale media sites: separate media migration and offloading
- Media separation involves moving files to a different storage location.
- Why is the main focus of the migration on media, rather than on servers?
- The safest approach is to avoid moving it all at once.
- Why do images sometimes become corrupted after only transferring the files?
- First, consider the operating conditions before looking at the site size.
- Frequently Asked Questions.
- WordPress related links
When migrating a large WordPress website, the real burden isn’t the WordPress core itself, but rather the endless stream of images, videos, and document files that accompany it.
Should media files be moved outside the web server? To put it simply, if the files are tens to hundreds of GB in size, or if there are a large number of visitors, separating them is advantageous. However, if the order of operations is incorrect, the images may disappear as if they were ghosts.
Media separation involves moving files to a different storage location.
WordPress typically stores media files in the wp-content/uploads directory. The information for images and media files used in posts is also linked based on this location.
The separation process involves moving image, video, and document files from the disk of the server where WordPress is running to a separate storage location. The offloading process is the step where the storage or CDN directly delivers the media to the visitors.
There is an unexpected pitfall here. When you upload a single image, you don’t end up with just one original.
WordPress creates thumbnails and several intermediate-sized files based on the specified size. The attachment information also stores the relative path of the original file and the paths of these smaller files.
Why is the main focus of the migration on media, rather than on servers?
When migrating a website, the bottlenecks are not the copying of the main files, but rather the time it takes to copy media files and the amount of storage space required. The download traffic generated each time a visitor views an image also puts a strain on the web server.
A more troublesome issue is the previous address. The official WordPress migration documentation also explains that when changing servers or domains, the previous address may remain in the database and within the posts, and that image links need to be checked separately.
While it might seem like simply searching and changing addresses at once would suffice, doing so could corrupt the serialized data of themes and widgets. In other words, a media migration is not just about copying files; it’s a task that involves coordinating files, addresses, and databases.
The safest approach is to avoid moving it all at once.
For large-scale websites, it is generally advantageous to separate media files into a separate object storage system. However, do not rush into offloading; instead, verify that the original and existing addresses are still valid before gradually transitioning.
Object storage is a storage system that stores files as objects. Storage systems like S3 are designed to store files of varying formats, such as images and videos, ranging in size from gigabytes to petabytes.
By using a CDN (Content Delivery Network), files that are frequently requested can be delivered from nearby edge locations. CloudFront uses a storage service or web server as the origin server and delivers cached files from the edge, thereby reducing requests to the origin server.
Therefore, it is safer to follow this order.
- First, preserve the origin server and the database.
- Compare the media files with the attachment information.
- The files are copied to a separate storage location.
- It connects the CDN with the media delivery address.
- Check the featured posts and new uploads.
- After checking for 404 errors and thumbnails, the original files are cleaned up.
Why do images sometimes become corrupted after only transferring the files?
Simply placing files in a storage location does not automatically change the existing WordPress address. To allow visitors to request files via the CDN address or the connected user domain, the delivery path must be changed.
Permissions must also be verified separately. Objects in an S3 bucket are, by default, private, so if you want to allow access only through a CDN, you need to configure separate access permissions.
Caching is a double-edged sword. While it can reduce repetitive requests to web servers when functioning correctly, if incorrect files or outdated addresses remain in the cache, users may continue to see broken pages even after the files have been corrected.
It is important to be cautious about sending all files to low-cost storage tiers simply because the storage appears inexpensive. Even transferring frequently accessed images can increase costs beyond expectations due to the minimum storage duration and the fees associated with retrieving the files.
When migrating data directly, the most common issue is the inconsistency between the file list and the database. For example, the copy process might complete, but the path to a mid-sized attachment file might be missing, or the post might still contain the old address.
If the site is currently in operation, then newly uploaded files also pose a problem. If writing is restricted at the last moment and incremental synchronization is not performed one more time, then images uploaded immediately after the migration may not be present in the new storage location.
First, consider the operating conditions before looking at the site size.
If the media size is less than tens of GB and the traffic is low, it is better not to be overly ambitious. Copy the entire uploads and the database to the new server together, confirm that it is working properly, and then postpone the offloading as a separate task to reduce the risk.
Conversely, if there are hundreds of gigabytes of media files or if image and video requests put a strain on the web server’s bandwidth and disk I/O, then separation is appropriate. By separating the storage space and the WordPress execution environment, you don’t have to move the entire media library every time you change servers.
It also becomes easier to back up and duplicate the original media. S3 provides protection features such as version control, object locking, and cross-region replication, allowing you to create separate recovery plans.
However, after the migration, you must not immediately delete the media files on the origin server. You need to check the number of files, the list, the paths to the original files and thumbnails, the image addresses of the existing posts, the newly uploaded files, and any 404 responses, in that order.
If any thumbnails are missing, you can regenerate them using the media regeneration feature of the WordPress command-line tool. It is safe to discard the old storage space only after the verification is complete.
Ultimately, the answer is simple. Smaller, less active sites should complete the entire migration first, while larger, more active sites should preserve the original content and gradually separate the media files into storage and a CDN.
Frequently Asked Questions.
Q. If only media files are moved to a separate storage location, does WordPress automatically connect them?
A. Existing addresses will not automatically change. You must check the metadata of attached files, the image addresses within the posts, and the CDN delivery addresses.
Q. When migrating, can I directly delete the uploads folder from the origin server?
A. It is not possible. You must check the file list, thumbnails, new uploads, featured posts, and 404 responses before deleting.
Q. If the media size is less than tens of GB, is offloading absolutely necessary?
A. If the number of visitors is low and the server can handle it, it is safer to complete the entire migration smoothly first. Offloading can be considered as a separate project later.
Q. Can this problem be easily solved using a tool? What kind of tool should be used?
A. You can use tools to assist with migration, backup, and media offloading. However, no tool can completely guarantee address verification, permissions, thumbnails, new uploads, or 404 checks, so you must verify these on the actual website.
Q. How do you move a website that is currently in operation to a new server without missing any new files?
A. Before the final switchover, restrict writing and proceed with the last incremental synchronization. After confirming new uploads and 404 responses, clean up the existing media.