Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Research and create steps for backend migration to Zappa #430

Open
arkid15r opened this issue Jan 12, 2025 · 17 comments
Open

Research and create steps for backend migration to Zappa #430

arkid15r opened this issue Jan 12, 2025 · 17 comments
Assignees
Labels

Comments

@arkid15r
Copy link
Collaborator

Describe the solution you'd like

Use https://github.com/zappa/Zappa for OWASP Nest backend.

@github-project-automation github-project-automation bot moved this to Backlog in Project Nest Jan 12, 2025
@arkid15r arkid15r moved this from Backlog to Todo in Project Nest Jan 12, 2025
@AbhayTopno
Copy link
Collaborator

@arkid15r can you please assign this to me please

@Naveen-Pal
Copy link
Collaborator

@arkid15r , I am familiar with serverless, can i get this one?

@harsh3dev
Copy link
Collaborator

@arkid15r @Naveen-Pal
What are the advantages of this migration for our project?

@Naveen-Pal
Copy link
Collaborator

Naveen-Pal commented Jan 12, 2025

@arkid15r @Naveen-Pal
What are the advantages of this migration for our project?

Serverless help to save cost as it is based on pay as you go and FAAS (function as a service)
It also does auto scaling as per the traffic.

In short, if no one is using the website it can automatically downscale to 0 (no cost). And up scale as per demand of service.

@Rajgupta36
Copy link
Collaborator

Rajgupta36 commented Jan 12, 2025

@arkid15r @Naveen-Pal
What are the advantages of this migration for our project?

Serverless help to save cost as it is based on pay as you go and FAAS (function as a service) It also does auto scaling as per the traffic.

In short, if no one is using the website it can automatically downscale to 0 (no cost). And up scale as per demand of service.

I am also curious about Zappa's serverless mechanism.
I have worked with Cloudflare Workers, which use Hono for serverless deployment. However, when the server receives no requests, it triggers a cold start mechanism, which takes some time to respond to the first API request @Naveen-Pal and @arkid15r?

@Rajgupta36
Copy link
Collaborator

Rajgupta36 commented Jan 12, 2025

is it better than ASG's+ load balancers or Kubernetes pods (k8s pods) for server scaling and traffic handling ?

@harsh3dev
Copy link
Collaborator

@arkid15r @Naveen-Pal
What are the advantages of this migration for our project?

Serverless help to save cost as it is based on pay as you go and FAAS (function as a service) It also does auto scaling as per the traffic.
In short, if no one is using the website it can automatically downscale to 0 (no cost). And up scale as per demand of service.

I am also curious about Zappa's serverless mechanism. I have worked with Cloudflare Workers, which use Hono for serverless deployment. However, when the server receives no requests, it triggers a cold start mechanism, which takes some time to respond to the first API request @Naveen-Pal and @arkid15r?

@Rajgupta36 I was also curious about the same as in hono, this behavior happens as you told.

@Naveen-Pal
Copy link
Collaborator

Naveen-Pal commented Jan 12, 2025

@Rajgupta36 Yes, you are right about the cold start, as you mention it take time for the first request but also make much impact on cost. Alternatively we can configure to have minimum 1 pods running.

is it better than load balancers or Kubernetes pods (k8s pods) for server scaling and traffic handling ?

In term of cost and scalibility serverless is the best option.
I think load balancers can not autoscale by itself (just distribute traffic among running pods).

@Rajgupta36
Copy link
Collaborator

Rajgupta36 commented Jan 12, 2025

@Rajgupta36 Yes, you are right about the cold start, as you mention it take time for the first request but also make much impact on cost. Alternatively we can configure to have minimum 1 pods running.

is it better than load balancers or Kubernetes pods (k8s pods) for server scaling and traffic handling ?

In term of cost and scalibility serverless is the best option. I think balancers can not autoscale by itself (just distribute traffic among running pods).

I think the combination of ASG's and load balancer is good for horizontal scaling . it's also cost efficient. also in asg we can describe min and max no of active machines.

@abhayymishraa
Copy link
Collaborator

@Rajgupta36 @Naveen-Pal provisioned concurrency maybe solve the cold start problem, by setting min no. of machines need to be active !!!!

@Naveen-Pal
Copy link
Collaborator

@Rajgupta36 Probably we don't need to use ASG's.
No, you cannot use ASG with Zappa because ASG is designed for managing EC2 instances, while Zappa deploys apps to AWS Lambda, which is a completely serverless service.

@Rajgupta36
Copy link
Collaborator

@Naveen-Pal i am not saying use ASG with zappa .
Zappa is a serverless framework, while ASG serves a different purpose. What I’m suggesting is to create Target Groups, then a Launch Template, followed by ASGs and a Load Balancer.
this is just a suggestion and not something I’m insisting on implementing

@Rajgupta36
Copy link
Collaborator

Rajgupta36 commented Jan 12, 2025

i think it's a good discussion on deployment approaches .
it is a good article for all of use :- https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtime-environment.html

@arkid15r
Copy link
Collaborator Author

This approach seems easier than k8s based. But I'm open to assess pros and cons of both approaches before choosing the direction. @Naveen-Pal will you be able to extend the task w/ a comparison of zappa vs k8s approach?

@Naveen-Pal
Copy link
Collaborator

One popular method to go serverless with Kubernetes is by using Knative.

Steps Required:

Setup the Environment:

  • Install kubectl, minikube, and kn (Knative CLI).
  • Set up Knative components (Serving and optionally Eventing).

Containerize the Application:

  • Build Docker images for each service(located in the backend directory)..

Create Knative Service Definitions:

  • Define a Knative Service for each service in the application using YAML configuration files.

And finally, manage deployment...

(This approach seems overly complicated.)


Zappa

For simpler deployments and lower operational overhead, Zappa is a great fit.

Steps:

Setup the Environment:

  • Simply run pip install zappa.
  • Add a zappa_settings.json file with the required configuration.

Deploy to Production:

  • Use zappa deploy production.

We will need to consider how this integrates with our CI/CD pipeline.


Personally, I believe Zappa is a better choice for our project since we are using Django. It simplifies the deployment process and reduces complexity.

@arkid15r
Copy link
Collaborator Author

It seems Zappa wins for now. But what would be k8s most important benefits for us if we are willing to deal with the complexity of the solution?

@Naveen-Pal
Copy link
Collaborator

Naveen-Pal commented Jan 13, 2025

one can migrate Kubernetes to any cloud but zappa is tied to AWS

@arkid15r arkid15r moved this from Todo to In progress in Project Nest Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: In progress
Development

No branches or pull requests

6 participants