GCP: Storage Sharing Options for Virtual Machines
Tags: googlecloud, webdev, devops, cloud
Published: 2024-01-25 08:28:17

While working on a project involving the processing of a large number of photos within a pipeline, we encountered a challenge: efficiently sharing storage across multiple VMs on Google Cloud Platform (GCP). We explored various options to address this issue:

## 1. GCP Cloud Storage
### Pros:
- **Scalability:** GCP Cloud Storage provides virtually unlimited scalability to meet growing storage needs.
- **Global Accessibility:** Storage buckets can be accessed from any location, promoting collaboration across different regions.
- **Managed Service:** Google Cloud Storage is a fully managed service, reducing administrative overhead.

### Cons:
- **Latency:** Accessing data from Cloud Storage may introduce some latency compared to local storage solutions.
- **Cost:** While the first 5 GB of storage is free, costs can escalate based on usage, potentially making it expensive for large-scale storage needs.

## 2. Persisted Disk Sharing
### Pros:
- **Performance:** Shared disks on n2 machines can provide high-performance storage solutions.
- **Integration:** Seamless integration with other GCP services for a comprehensive cloud computing environment.

### Cons:
- **Cost:** N2 machines can be expensive, making this solution less cost-effective for smaller budgets.
- **Limited Sharing:** Only two VMs can share a single disk, which may not be sufficient for larger deployments.

## 3. Filestore
### Pros:
- **Managed NFS:** Google Cloud Filestore offers a fully managed Network File System (NFS), simplifying storage management.
- **Performance:** Filestore is optimized for high throughput and low latency, making it suitable for various workloads.

### Cons:
- **Cost:** Filestore can be relatively expensive compared to other storage options, especially for large storage requirements.
- **Limited Protocols:** Filestore primarily supports NFS, which may not be suitable for environments requiring different protocols.

## 4. NFS (Network File System)
### Pros:
- **Compatibility:** NFS is widely supported across various operating systems and platforms.
- **Simplicity:** Setting up NFS for sharing storage is relatively straightforward and well-documented.

### Cons:
- **Performance:** NFS may not be ideal for high-throughput scenarios and may introduce latency compared to other solutions.
- **Security:** NFS relies on the underlying network for security, and proper configuration is crucial to avoid potential vulnerabilities.


After initially implementing GCP Cloud Storage, we encountered a significant performance drop, prompting us to explore alternative solutions. Recognizing the impact of the latency on our processing time, which initially took 2 minutes and 40 seconds to handle 1000 images with a total size of 1.48 GB, we decided to shift to a different approach. 


To address cost considerations, we chose to manage NFS ourselves rather than relying on GCP's managed service. The transition to our self-managed NFS solution resulted in remarkable improvements, reducing the processing time to an impressive 1 minute and 15 seconds for the same set of 1000 images. This not only demonstrated the efficacy of our chosen approach but also underscored its cost-effectiveness. 

For those interested in setting up NFS on a GCP VM and achieving similar performance gains, numerous resources are available in articles and documentation to guide you through the process.

## Conclusion
Selecting the right storage sharing method for VMs depends on factors such as performance requirements, budget constraints, and specific use cases. Each option has its advantages and drawbacks, and careful consideration is essential to ensure optimal resource utilization in cloud environments. By understanding the pros and cons of GCP Cloud Storage, persisted disk sharing, Filestore, and NFS, cloud architects can make informed decisions when designing storage solutions for virtualized environments.

Good reads:
What is NFS? - https://www.atera.com/blog/what-is-nfs-understanding-the-network-file-system/

Object vs File Storage - https://blog.purestorage.com/purely-informational/object-vs-file-storage-when-and-why-to-use-them/


Feel free to reach out if you have any questions or need further clarification.