Introduction
As part of my company, AHMESEN's latest offering Lightwire Drops, I was tasked with designing the system architecture of the product.
In this post we will go over the several challenges I have faced in developing this system, both from a Cost perspective, as well as Development and System limitations.
The Challenges
This project had several key challenges. These include:
- Storage Costs
- Data Read Costs
- CDN limitations
Storage Costs
In order to overcome the cost limitation, we decided the best method would be to use a solution such as object storage. Block storage would be inefficient at both a cost perspective, and a scaling perspective. After exploring solutions, we came across Clpudflare R2.
Data Read Costs
One challenge for read costs was actually loading the files that users have uploaded. We knew from the start that our users would be using our link sharing feature to share across social media, which could result in the potential of thousands to millions of hits. The costs at that point would hit levels at which our service, especially at the free tier would become unsustainable. However, we discovered that we can utilise cloudflare directly in order to serve the files. This yields the advantage in that files that are loaded constantly will end up being cached, which reduces actual operations on the storage bucket.
As a result we would be better insulated from the higher costs of Class B operations, versus frequent files being loaded from Cache.
CDN Limitations
The challenge with using Cloudflare's CDN for our product would be that using the CDN would require the domain used to be linked to Cloudflare unless switching to a more expensive tier. This would be an issue as we plan on allowing users to link their own domains or subdomains to our product to use customised URLs.
However we figured out a way around this. By purchasing a domain and linking it to Cloudflare, we could use said domain to serve the image files. In turn, we setup a lightweight serving utility on our own servers, that serves an extremely minimal page, but also provides space to embed the image. Using Server Side Rendering and templates, we can utilise the src from the domain linked to the Cloudflare CDN, while at the same time still maintaining user domain usability. This system also supports our social media redirects, which are used when a link is detected to be posted on Social Media. Our system intelligently detects the use of a Social Media platform's crawler and will in turn return a redirect directly to the CDN URI, instead of serving our template webpage, allowing for direct embedding into the site.
Conclusion
After a period of Trial & Error, I was able to get the system stable and deployed onto both Cloudflare, and our own systems. By doing so this results in a low-cost sustainable model for our product to grow on. By using Object Storage buckets, we also plan to add more speed reducing capabilities by introducing independent upload regions, which will allow direct uploading to the newest bucket region, instead of uploading onto a single centralised region.