Every Monday on Twitch, I work on a project with the goal of learning something new. My first project I'm working on is a Twitter bot for Philip DeFranco. Philip DeFranco is an established OG YouTuber who has a long running daily news show that I frequently watch.
The goal of this project is to create a bot that tweets out all of the news videos Philip DeFranco published that day in the past - a way to look back in history that day and see how the world has changed and progressed. The world moves fast, and a thing that might seem like a huge deal a year ago may be a resolved problem today. We should be able to easily look back and learn from our history - and this is my fun way to do so.
So, say today is March 20th, 2021 - the bot will share the video from March 20 2017, March 20 2018, March 20 2019, and March 20 2020.
When you hear functions, you probably think things like methods, classes, and constructors. Chunks of code that come together to make an action that can be called in other places of code.
But in the world of DevOps and Servers, functions have a different.... function.
Introducing serverless functions - and before you ask, yes there are servers involved.
The name “serverless” is a lie. Serverless processes actually do involve servers - but they're called “serverless” for one important reason.
Utilizing a serverless architecture enables the developer to no longer have to worry about maintaining servers. Prior to the invention and offering of serverless, there were (and still are) teams of people whose entire job was to ensure that servers were created properly, run correctly, and remain running. In addition, individual developers looking to launch their own private projects onto the internet had to figure out how to deploy servers and maintain their own uptime.
You can think of it as a shift in responsibility - now, developers don't have to worry any more about server allocation (making sure there's enough servers available), uptime, and more. Instead, the company hosting your serverless project is in charge of scaling, uptime, etc. So all the developer has to do is write code.
The program that you deploy to that serverless service is called a function. Hence, serverless functions.
If you're interested in learning more about serverless functions, and FAAS (Functions as a Service), I'd highly recommend checking out this article from PubNub which does an excellent job explaining the concepts and this iconic blog post from Serverless.com which explains the history and pros/cons of serverless.
Beyond the ease of not having to worry about servers for this project, serverless architecture has created a powerful tool that goes beyond server maintenance. Serverless functions can also act as a sort of end point - only run when called upon or only run when scheduled.
"Only run when scheduled, you say?"
Yes, only run when scheduled - which sounds exactly what I need for a program that only needs to run once a day to run a small number of api queries and calls.
Through serverless function events, I can program the application to start up and run daily in the morning, execute queries, and then shut down. I don't have to worry about having to maintain uptime on the server and constantly checking the time to see if it's time to execute the API calls/queries. Not only does this save me hassle/headache, it saves me money. A server with constant uptime is not cheap - serverless functions allow me to run the server on an as needed basis.
I'm really excited to build this project, learn more about serverless functions, as well as build my first side project with Python. If you want to watch me create this fun little bot, you can tune into my Twitch channel every Monday afternoon where I work on this project LIVE!
For the extra curious, you're probably wondering if New Relic works with serverless architecture. Yes, it does - check it out here.