When talk comes to serverless, engineers have lots of questions. Here are some answers 😊
What the heck is serverless?
Serverless is other people's servers running your code. The latest step in the evolution from full DoItYourself servers running on a machine you own towards "I just want a piece of code to run when you hit a URL"
The core innovation are virtual servers small and fast enough to wake up on every request. This enables perfect automatic scaling to your traffic.
PS: You can see me answer some of these in a recent video 👇
What would be the best way to change data (like toggling a boolean value via Lambda) to change the state of the SSG/ISR Next.js app?
A common use-case for serverless is to rebuild your JAMStack static website when data changes. User action or database event triggers your serverless function, your code makes a request to the "Redeploy Webhook" that most providers offer, and voila: updated website.
Calling the webhook is a basic
fetch() request. You could even do it from the browser ✌️
So should you be using lambda instead of firebase cloud function?
Choosing providers is tricky. Depends on what you're doing and what you're looking for.
And when you outgrow Firebase's native way of doing things, or need anything custom at all, you're shit out of luck.
Can you talk about the pros and cons of freelancing with serverless as your specialty?
In freelancing and consulting circles this is called "positioning" or "niching down". Great terms to Google.
A basic positioning statement would be "I transition growing B2C startups to serverless so they can scale faster without downtime".
The goal is to sell a business benefit and be known as The Person for your thing. Makes you easier to hire, easier to recommend, faster to remember.
Does lambda work with relational database? Or does it just work with dynamo?
Dynamo is used in tutorials because it's quick to set up and unlike traditional databases, you need not worry about swamping your database with requests.
But dynamo isn't great for typical application data.
Is not there a problem with the cold start for apps, which has low traffic?
Cold starts are a common concern with serverless. That's when a new user hits your dormant server and needs to wait for code to warm up.
Huge problem before serverless came along. Services like Heroku, shared hosting, and even (mismanaged) DIY servers experienced huge cold start latency.
1 second to get an API response is no good. 😅
If that's too slow, AWS recently added a feature that keeps your lambda warm.
What is your preferred cloud provider for serverless?
Personally I like AWS. It's become the industry standard, has more services than I'll ever need, and it's free for all but the biggest side projects.
Vercel and Netlify are great for static hosting and simple cloud functions. Access to the rest of AWS's ecosystem can be hard.
Firebase I've used for experiments and it felt cumbersome. My brain doesn't work that way.
Haven't found an excuse yet to try Azure :)
How about operation like CI/CD on serverless?
Continuous integration and deployment is where serverless shines!
With infrastructure-as-code you define your whole app in your code. Frontend, backend, server, database, queues, everything. It's all there in your version control.
That means every pull request, every branch, every feature, can have its own deploy with its own infrastructure and custom URLs. Run as many as you want in parallel 🤘
You get a fantastic integration experience.
Wanna automate the testing itself? Serverless is great at running code on demand ;)
How to handle more complex Database queries where you would normally use an ORM and models? How to share those between functions?
Decent libraries exist from the Backbone era (circa 2012) but they feel weird in modern days. And it's hard to modernize when a lot of existing code depends on your library.
TypeScript-based ORM approaches have cropped up in recent years and they look like small pet projects. You wouldn't wanna bet your company on those just yet.
Prisma feels like the most serious play in this space right now. They've got a great SQL builder with fantastic TypeScript support. I haven't had a chance to try it yet.
You can always use SQL directly. That always works :)
Got more questions? Hit reply
PS: my new Serverless Handbook launches on Wednesday and if you buy this week will have a chance to win a signed copy
Leave your email and be among the first to know when Serverless Handbook launches.
The perfect resource that shows you how to jump into modern backend and understand any backend. A why and how book.
Learn everything you need to dive into modern backend. Understand any backend
these chapters gave me knowledge which is sufficient to build real products and the hand-drawn diagrams and high-leveled descriptions gave me the feeling that i don't have any critical "knowledge gaps"
Launching soon, be the first to know.
Ready to Stop copy pasting D3 examples and create data visualizations of your own? Learn how to build scalable dataviz components your whole team can understand with React for Data Visualization
Curious about Serverless and the modern backend? Check out Serverless Handbook, modern backend for the frontend engineer.
Ready to learn how it all fits together and build a modern webapp from scratch? Learn how to launch a webapp and make your first 💰 on the side with ServerlessReact.Dev
By the way, just in case no one has told you it yet today: I love and appreciate you for who you are ❤️