The client sought a cost-effective alternative to AWS for serverless WordPress hosting, preferring a pay-as-you-go model to control expenses. They wanted to minimize costs while maintaining performance, security, and scalability. They specifically requested that all WordPress files, including core files and media, be stored and served from a Cloudflare R2 bucket to avoid high costs associated with separate storage volumes for each website.
Challenges
We chose DigitalOcean for hosting due to its affordability and designed a budget-conscious solution. We combined multiple automated tools (APIs) for efficient deployment and management, used Cloudflare R2 for storage due to its zero ingress costs, and implemented Kubernetes for dynamic resource management, all tailored to meet the client’s budget and performance needs.
Solution
1.API Development:
Database & DNS Records API:
Automated the setup and deletion of databases and DNS records to streamline the process.
R2 Bucket API:
Managed the creation and deletion of Cloudflare R2 storage buckets for cost-effective storage.
Kubernetes API:
Managed user-specific environments and resources like secrets, services, and ingress.
Central Controller API:
Coordinated all APIs for streamlined WordPress setup on Kubernetes with minimal input.
2.WordPress Hosting:
Developed a custom WordPress image and deployed APIs on DigitalOcean’s App Platform.
Employed a cost-effective storage strategy by initially serving all WordPress files directly from Cloudflare R2 to avoid separate storage volumes.
3.Performance Challenge and Our Solution:
Initial Challenge
Serving all files from Cloudflare R2 caused slower response times, especially under heavy traffic.
Client Budget Limitations
Prevented the use of dedicated storage volumes for each website..
4.Solution:
High Availability (HA) Storage:
Implemented a custom NFS HA cluster for WordPress core files, ensuring fast access and improved performance.
Optimized Use of R2:
Continued using Cloudflare R2 for less frequently accessed media files, maintaining low costs.
Secure Access:
Used SFTP for secure access to storage.
5.Automation:
The Central Controller API automated the entire setup, from database creation to DNS configuration, Kubernetes resource deployment, storage mounting, and SSL-enabled WordPress installation, reducing setup time to 30-40 seconds.
6.Monitoring & Autoscaling:
Implemented Grafana and Prometheus for real-time monitoring of Kubernetes and NFS clusters, with alerts for infrastructure issues.
Enabled autoscaling to optimize resource use and control costs.
Client Budget Constraints vs. Performance Needs:
The client’s budget limited the use of dedicated storage volumes for each site, making storage a concern.
Initially, using Cloudflare R2 for all files caused performance issues. A hybrid solution was implemented, using Cloudflare R2 for media files and an NFS HA cluster for core files to balance cost savings with performance.
Cost Considerations::
DigitalOcean’s App Platform and Kubernetes services charge on a pay-as-you-go basis, aligning costs with usage.
Cloudflare R2’s zero ingress fees significantly reduced storage costs.
The NFS HA cluster was a cost-effective alternative to multiple expensive storage volumes.
Benefits
1.Cost Savings:
Reduced costs by switching from AWS to DigitalOcean and using a combination of Cloudflare R2 and NFS for storage.
2.Improved Performance:
Faster WordPress hosting with high availability and optimized storage.
3.Scalability:
Dynamic scaling of resources ensures the client only pays for what they use.
4.Automation:
Fully automated deployment minimizes setup time and manual effort.
4.Security:
Ensured secure access with SFTP and SSL, meeting compliance standards.
Conclusion
Our serverless hosting solution on DigitalOcean, enhanced with Cloudflare R2 and a custom NFS cluster, successfully addressed the client’s needs for cost control, scalability, and performance.