serverless backend
serverless backend
backend
what is backend?
backend refers to the server-side processes that manage the logic, database interactions, and overall functionality of web applications, which users do not see. you might have used express to create the backend server. and the way the server runs is usually is node index.js which start a process on a certain port (8000 for example)
you have to deploy the backend on the server so other people can access it and there are few ways to deploy your application on the internet.
there are some cloud computing platform which can let you rent a virtual machine and deploy your application (you can run on your laptop as well, but it can't run 24 hours). some cloud computing platform:
- aws
- azure
- cloudflare
there are few things you need to take care of it along with deploying your application on the cloud.
- taking care of how and when to scale
- base cost (even if on one is visiting the app)
serverless backend

it is similar like code and push the github vercel automatically deploy the application on the internet.
we just have to write the backend code and run the command the app will automatically deploy, auto scale and can also charge per request (better than paying for virtual machine)
but there are few problems with that like it's become more expensive at scale and cold start problem.
serverless providers
- aws lambda
- google cloud function
- cloudflare worker (we are going this to deploy our app because no credit card required to deploy one app)
cloudflare worker setup
sign up on :
https://www.cloudflare.com/some of resources to learn and understand how cloudflare worker works?
cloudflare workers don't use the node.js runtime. they have created their own runtime.
node.js runtime?
node.js is a runtime environment that allows javascript to be executed on the your local machine. it is built on the v8 javascript engine from chrome, which compiles javascript into machine code.
try creating a test worker from the ui (common worker examples) and try hitting the url at which it is deployed

initializing a worker
initialize a worker
npm create cloudflare -- serverless-backend
// Select no for Do you want to deploy your application
start the worker locally
npm run devbasic server (try to write you own code)
import { Hono } from 'hono'
const app = new Hono()
app.get('/', (c) => {
return c.text('Hello from serverless backend!')
})
export default appor try to clone/download this repo https://github.com/notcodesid/serverless-backend
deploy your server
login to cloudflare via the wrangler cli
npx wrangler logindeploy your application
npm run deploythat's it. you've deployed the application on the server.
for notes details check harkirat noteshttps://projects.100xdevs.com/tracks/eooSv7lnuwBO6wl9YA5w/serverless-1
until then,
siddharth