Cost Considerations - sebas0163/My_RESTaurante GitHub Wiki

RESTaurant System Architecture

The RESTaurant system architecture was three Google Cloud Functions, one storage bucket, and a Firestore database.

Now we will migrate this to be a infrastructure of: four microservices hosted in a local kubernetes infrastructure using minikube, the web app will also be hosted in a container inside the kubernetes infrastructure, but maintaining the firestore database.

Due to the project's small scale, the cost parameters are minimal.

Minikube Hosting:

  • Local Development: If Minikube is used for local development and testing, there are no direct cloud hosting costs. However, for production, you would typically transition to a managed Kubernetes service or a self-hosted Kubernetes cluster.

  • Self-Hosted Kubernetes Cluster:

    • Compute Costs: Varies depending on the number of nodes and their specifications.
    • Example: Assume 3 nodes, each with 4 vCPUs and 16 GB RAM.
    • Estimated cost per node (on a cloud provider like AWS/GCP/Azure): $50/month (varies by provider and instance type).
    • Total Compute Cost: $150/month.

Databases: Firestore

  • Document Reads (per day): 10,000 ($0.00)
  • Document Writes (per day): 500 ($0.00)
  • Total Stored Data (per day): 10 GiB ($1.22)

Serverless vs. Kubernetes Costs

  • Serverless (Cloud Functions):

    • Memory Allocated: 256 MiB (.167 vCPU) ($8.61)
    • Requests per month (millions): 1 Million ($0.00)
    • Average execution time per request (ms): 600 ms
  • Kubernetes (Minikube):

    • Pod Memory Allocation: Assume similar allocation per microservice (256 MiB per microservice).
    • Total Memory: Assuming 5 microservices, 256 MiB each = 1.28 GiB.
    • CPU Allocation: Assume each microservice gets 0.2 vCPUs = 1 vCPU total.
    • Compute Cost: Included in node cost above.

Storage Costs

  • Cloud Storage:

    • Total Amount of Storage: 10 GB ($0.33)
    • Storage Type: Regional Standard Storage
  • Persistent Volumes in Kubernetes:

    • Total Storage Required: 10 GB.
    • Estimated Cost: Varies by provider, typically $0.10 per GB.
    • Total Estimated Cost: $1.00/month.

Total Estimated Cost

  • Compute Costs: $150/month (for a 3-node cluster on a cloud provider)
  • Firestore Database Costs: $1.22/month
  • Storage Costs: $1.00/month
  • Other Costs: (e.g., networking, management overhead): Varies Total Estimated Cost: 52.22/month

To lower the cost, one would need to adjust the parameters. However, in a larger scale application, the parameters would need to adapt to the requirements and potential customers. Another approach to reducing costs is by opting for South America servers, as North American servers tend to be more expensive but depending on where the users are located this change could generate a lot of delays in the responses and be harmful to the service.