Aurora Serverless Data API: A First Look

On Tuesday, November 20, 2018, AWS announced the release of the new Aurora Serverless Data API. This has been a long awaited feature and has been at the top of many a person’s #awswishlist. As you can imagine, there was quite a bit of fanfare over this on Twitter.

Obviously, I too was excited. The prospect of not needing to use VPCs with Lambda functions to access an RDS database is pretty compelling. Think about all those cold start savings. Plus, connection management with serverless and RDBMS has been quite tricky. I even wrote an NPM package to help deal with the max_connections issue and the inevitable zombies 🧟‍♂️ roaming around your RDS cluster. So AWS’s RDS via HTTP seems like the perfect solution, right? Well, not so fast. 😞

Continue Reading…

Off-by-none: Issue #11

After this, there is no turning back

Welcome to Issue #11 of Off-by-none. I’m happy that you’re here! 🙌

Last week we recapped ServerlessNYC and talked quite a bit about serverless adoption. This week we’re going to point out some more resources for those getting started, as well as offer up plenty of options if you’re looking to take the red pill and go down the serverless rabbit hole. 🐇

Here we go! 🕺

What to read when you want to amp up your serverless knowledge… 🔈

Danilo Poccia has written a free ebook, Agile Development for Serverless Platforms. This book is over 100 pages and has a great section on architectural patterns. There is plenty to learn from this free resource and it is well worth a look. 📖

The team over at Financial Engines wrote a guide to help us with managing disaster recovery with DynamoDB. AWS DynamoDB: Backup and Restore Strategies looks at both Point-in-Time Recovery and On-Demand Backups. Lots of useful information here including configuration and pricing. 👨🏻‍💻

Finally, Thundra published a great piece that shows us how to Debug AWS Lambda Node.js Functions in Production Without Code Change. I really like the idea of automated instrumentation as it cuts down the burden on developers and keeps your code a bit cleaner. It can also ensure we don’t lock ourselves in to a specific software vendor. 📈

When you want to get started with serverless… 🏋️‍♂️

There have been a lot of new “Getting Started with Serverless” posts this week. I really like that more people are starting to create this type of content. The more that’s out there, the more likely someone is to come across it and get to that serverless “aha” moment. If you’re new to serverless, here are a few posts to get you started:

And don’t forget that the #NoServerNovember Challenge (hosted by Serverless, Inc.) is still going on. These challenges will give you something interesting to work on and let you go beyond the standard “Hello World” tutorial.

When you’re not ready to give up RDBS with serverless… 🤓

In our inaugural issue we introduced the serverless-mysql package with my Managing MySQL at Serverless Scale post. David Zhang (@Zigzhang) has taken this even further and created a five part series to help others get started. In his first post, Serverless & RDBS (Part 1) — Set up AWS RDS Aurora and Lambda with serverless, David lays out some background, then gives you full examples to get you up and running.

He’s also published Part 2 (Set up EC2 instance to securely connect to your Aurora DB) and Part 3 (Set up database migrations with umzug) with the final two parts (Set up continuous deployment to migrate database with CircleCI and Set up local development environment with serverless-offline and Docker) coming soon. These are sure to be helpful guides for anyone looking to build serverless apps with RDBS backends.

Of course, re:Invent is right around the corner, so let’s hope we get HTTP endpoints for RDS! 😬

When you feel like there are a lot of conferences… ✈️

Speaking of re:Invent, it is less than two weeks away! 🎉 This is the first year that I’m attending so I’ve been looking for tips like this and this. I’m excited for some of the sessions I’m attending and will be at several events as well. If we haven’t connected already, please contact me so we can meet up.

In other conference news, Serverless Computing London is happening right now and it is chockfull of great speakers. Follow their Twitter feed to see some snippets from the event. Some of the slide decks have been posted as well, so check those out. I was looking at Timirah James’ Function Composition in a Serverless World talk, good stuff. Hopefully we’ll see the videos posted soon. ⚡️

Also, ServerlessDays BOSTON finally has a date! The event is scheduled for March 12, 2019 at the Microsoft New England Research & Development Center. More information about our call for papers and sponsorship opportunities is coming soon. 🎊

When you realize that AWS has no plans to slow down their serverless innovations… 🚀

AWS has released several new features recently that could have a profound impact on our serverless applications. Some of these are pretty exciting. Now just imagine what they are going to announce at re:Invent! Here are just a few of the recent updates:

Serverless Star of the Week ⭐️

There is a very long list of people that are doing #ServerlessGood and contributing to the Serverless community. These people deserve recognition for their efforts. So each week, I will mention someone whose recent contribution really stood out to me. I love meeting new people, so if you know someone who deserves recognition, please let me know.

This week’s star is Alex Casalboni (@alex_casalboni). Alex is an AWS Technical Evangelist, Serverless champion, co-organizer of ServerlessDays Milan and the serverless meetup there, contributor to serverless open source projects, and a regular conference speaker spreading the serverless gospel. He also helps coordinate ServerlessDays conferences around the word, including helping me and the Boston team. Thanks for all you do, Alex!

Final Thoughts 🤔

As much as I still worry that serverless adoption will be slower than I had hoped, the amount of innovation and new faces in the community is really encouraging. I’m already aware of a few announcements planned for re:Invent, but I also know that there will be a ton more. Other cloud providers are also pushing serverless innovations, and I expect Google and Azure to be announcing new things soon as well.

Serverless still has a long way to go, but all of these new tools, platforms, cloud provider features, conferences, and enthusiasm from the community, is helping to expose this paradigm to a much larger audience. I’m going to continue to write and promote it as much as I can, because there is little doubt in my mind that this is the future of application development.

I hope you’ve enjoyed this issue of Off-by-none. Feedback and suggestions are always welcome and appreciated. It helps me make this newsletter better each week. Please feel free to contact me via Twitter, LinkedIn, Facebook, or email and let me know your thoughts, criticisms, and if you’d like to contribute to Off-by-none.

Go build some great serverless apps and spread the word. 📣

See you next week,

P.S. If you liked this newsletter, please share with your friends and coworkers. I’d really appreciate it! 😉

🚀 Project Update:

Serverless MySQL: v1.1.0 Released

Serverless MySQL v1.1.0 adds additional transaction support capabilities to allow users to retrieve interim query results for use with future queries. This is useful for getting the insertId from previous queries when performing transactions. Read More...

Off-by-none: Issue #1

The awaiting is the hardest part

Welcome to the inaugural issue of Off-by-none! 🎉 I’m so happy that you’re here. 🙌 For those of you that have been email subscribers for a while, this will look a little different. I hope you’ll stick with me; I think this will be interesting. For those of you that are new, welcome, and thank you for joining!

I’m a constant learner, and I’ve found one of the best ways to learn is to take great notes, and then share what you’ve learned with others. This is the goal of Off-by-none. Not to be perfect, not get on a high horse 🐴 and tell you what you should and should not do, but to encourage collaboration and experimentation. Let’s push the limits of serverless. Then let’s take what we’ve discovered, and disseminate it to the masses, so we can learn from each other’s mistakes AND successes.

This newsletter has been awhile in the making. I’ve got all sorts of ideas, but this too will be a constant experiment. Your feedback, ideas, contributions, and encouragement will go a long way to making this what I truly hope it will be. Please reach out to me and share your thoughts and suggestions. They will be greatly appreciated. 🙇‍♂️

Let’s get started!

When you have thousands of concurrents user and limited MySQL connections… 🚀

Lots of people think RDBMS and Serverless don’t mix, and unless you use a series of hacks and tricks, then you’re likely to have scaling problems given the way serverless containers handle concurrent connections. In the past, I’ve often mitigated this issue by increasing the max_connections setting and gracefully handling errors. But now with Aurora Serverless, you can’t change that setting, which means LOTs of Too many connections errors.

I’ll use DynamoDB for the majority of my serverless datastore needs, but it can’t match MySQL’s ability to create normalized data structures, enforce declarative constants, provide referential integrity, and enable ACID-compliant transactions. Sometimes, you just need a relational database. And sometimes, serverless forces us to think about things differently. 🤔

Even though serverless functions are stateless, we can still reuse connections. Not only that, but status commands, like retrieving the number of max_connections and counting threads from the PROCESSLIST, are fairly inexpensive queries. I decided to run some tests to see how efficiently (and effectively) serverless functions could manage their own distributed database connections. Turns out, pretty darn well! 😜

I spent some time and turned all my learnings from the past several years (as well as my new experiments) into a new NPM module called Serverless MySQL. It manages connections for you, cleans up zombies to maintain total connection use thresholds, and even makes working with MySQL connections in Node.js super easy by adding async/await support and simple transaction workflows. I wrote a post about it called Managing MySQL at Serverless Scale that goes into a lot more detail.

You should still size your MySQL instance/cluster appropriately, but for one of my tests, I simulated 500 concurrent users per second with only 90 connections available. Not only did Lambda and MySQL not throw any errors, but the average response time was only 41 ms with the max being just over 3 seconds. Not too shabby. Bump your max_connections up to something more reasonable for that kind of load, and you should never have to gracefully handle connection limit errors again. 🤘🏻

When you’re looking for some light serverless reading… 📚

I’ve had plenty to say about cold starts in the past, but how much do they really matter, and how do they compare across the Big-3 cloud providers (AWS, Azure, and Google Cloud)? Mikhail Shilkov does a pretty darn good job answering those questions in his post Serverless: Cold Start War. Definitely worth the read. ❄️

Erica Windisch start writing again too, and you won’t be disappointed. Lessons from building a Serverless Data Pipeline with AWS Kinesis and Lambda is a relatively short read, but it is loaded with invaluable insights. If you’re thinking about using Kinesis in production, you should probably read this. 🤓

Looking for some serverless best practices? Paul Johnston (yes, the Paul Johnston, legendary cofounder of ServerlessDays), published a post with some “relatively accepted” best practices. There is a lot of debate over these, and Michael Hart and Tyler Love from Bustle jumped in with quite a difference of opinion. Both the article and the Twitter thread are good reads.  I have a feeling that this isn’t the last of this debate. 🍿

Finally, sometimes things are better late than never. Chris Munns, AWS Senior Serverless Developer Advocate, put out a post that contains a quarterly recap of all things AWS Serverless. AWS moves so fast that it’s often hard to keep up with all their innovations. This post outlines all the cool stuff AWS did with Serverless in Q2 2018. ⚡️

When getting through airport security is harder than implementing serverless security… ✈️

I’ve got some travel plans coming up! I’ll be heading to ServerlessDays NYC on October 30th and I will be going to AWS re:Invent this year! I’m hoping to meet a lot of you in person, but I’ll also be taking copious notes and will be sure to share what I learn with all of you. If you’ll be at either event, connect with me via Twitter, LinkedIn, Facebook, or email so we can meet up (and maybe grab a few 🍻).

When you join the “My post made it to the front page of Hacker News and my site crashed” club… 🏅

I’ve been very grateful for all the positive responses to my Serverless Microservice Patterns for AWS post. Lots of people found it very useful and have been using it as a reference, which is great. Someone did me the honor of posting the link to Hacker News, and on Sunday it made its way to #7! Well, my self-hosted WordPress blog running on a single EC2 instance couldn’t handle the traffic, and my site crashed. 💥🤦🏻‍♂️

But it turns out that I’m in good company. Yan Cui had the same thing happen to him earlier this year. He decided to make his blog serverless by using Shifter, a service that converts your WordPress blog into a static, serverless site. I really like this idea, but at the same time, I’m also really sick of WordPress in general. I’ve actually been thinking about this for quite some time and should have more thoughts to share soon.

Serverless Star of the Week ⭐️

There is a very long list of people that are doing #ServerlessGood and contributing to the Serverless community. These people deserve recognition for their efforts. So each week, I will mention someone whose recent contribution really stood out to me. I love meeting new people, so if you know someone who deserves recognition, please let me know.

This week’s star is Slobodan Stojanović (@slobodan_). Not only did he write the book on Serverless Applications with Node.js, but he also has a number of great serverless posts (like here and here). But the reason I chose Slobodan this week is because of a recent talk he gave at Frontend Conference in Zurich. I wasn’t able to be there in person, but when I saw his slides, I was inspired. Convincing people to adopt serverless is a bit of a passion of mine, and the fact that Slobodan was introducing serverless to an entirely new audience (frontend developers) is a positive step towards more adoption. And, I’m also super jealous by how good his artwork is!

Final Thoughts

I hope you enjoyed this first issue of Off-by-none. It wouldn’t be possible without you and the contributions of a vibrant Serverless community. Please send me your feedback so I can continue to make this newsletter better each week. Reach out via Twitter, LinkedIn, Facebook, or email and let me know your thoughts, criticisms, or even how you’d like to contribute to Off-by-none.

Thanks again! And I hope to see you again next week! 🤞

Until then,

Aurora Serverless: The Good, the Bad and the Scalable

Amazon announced the General Availability of Aurora Serverless on August 9, 2018. I have been playing around with the preview of Aurora Serverless for a few months, and I must say that overall, I’m very impressed. There are A LOT of limitations with this first release, but I believe that Amazon will do what Amazon does best, and keep iterating until this thing is rock solid.

The announcement gives a great overview and the official User Guide is chock full of interesting and useful information, so I definitely suggest giving those a read. In this post, I want to dive a little bit deeper and discuss the pros and cons of Aurora Serverless. I also want to dig into some of the technical details, pricing comparisons, and look more closely at the limitations.

Audio Version

Continue Reading…

How To: Manage RDS Connections from AWS Lambda Serverless Functions

Someone asked a great question on my How To: Reuse Database Connections in AWS Lambda post about how to end the unused connections left over by expired Lambda functions:

I’m playing around with AWS lambda and connections to an RDS database and am finding that for the containers that are not reused the connection remains. I found before that sometimes the connections would just die eventually. I was wondering, is there some way to manage and/or end the connections without needing to wait for them to end on their own? The main issue I’m worried about is that these unused connections would remain for an excessive amount of time and prevent new connections that will actually be used from being made due to the limit on the number of connections.

🧟‍♂️ Zombie RDS connections leftover on container expiration can become a problem when you start to reach a high number of concurrent Lambda executions. My guess is that this is why AWS is launching Aurora Serverless, to deal with relational databases at scale. At the time of this writing it is still in preview mode.

Update September 2, 2018: I wrote an NPM module that manages MySQL connections for you in serverless environments. Check it out here.

Update August 9, 2018: Aurora Serverless is now Generally Available!

Overall, I’ve found that Lambda is pretty good about closing database connections when the container expires, but even if it does it reliably, it still doesn’t solve the MAX CONNECTIONS problem. Here are several strategies that I’ve used to deal with this issue.

Continue Reading…

How To: Normalize URLs Stored in MySQL

I came across an interesting problem the other day. As part of our URL normalization strategy at AlertMe, we have been adding a trailing slash to URLs without file extensions. We did a lot of research when deciding on this tactic and the general consensus around the web was to use trailing slashes for directories and (obviously) no slashes on filenames. See this article from the official Google Webmasters blog: (I know it’s old, but the concept is still relevant).

We even tested a number of publisher URLs to see what their redirection strategies were. Every one we tested responded correctly to both the slash and no-slash versions of the URL. Some redirected to a trailing slash, some redirected to no trailing slash, but they all returned (or redirected to) the intended page.

Continue Reading…

How To: Reuse Database Connections in AWS Lambda

Update 9/2/2018: I wrote an NPM module that manages MySQL connections for you in serverless environments. Check it out here.

I work with AWS Lambda quite a bit. The ability to use this Functions-as-a-Service (FaaS) has dramatically reduced the complexity and hardware needs of the apps I work on. This is what’s known as a “Serverless” architecture since we do not need to provision any servers in order to run these functions. FaaS is great for a number of use cases (like processing images) because it will scale immediately and near infinitely when there are spikes in traffic. There’s no longer the need to run several underutilized processing servers just waiting for someone to request a large job.

AWS Lambda is event-driven, so it’s also possible to have it respond to API requests through AWS’s API Gateway. However, since Lambda is stateless, you’ll most likely need to query a persistent datastore in order for it to do anything exciting. Setting up a new database connection is relatively expensive. In my experience it typically takes more than 200ms. If we have to reconnect to the database every time we run our Lambda functions (especially if we’re responding to an API request) then we are already adding over 200ms to the total response time. Add that to your queries and whatever additional processing you need to perform and it becomes unusable under normal circumstance. Luckily, Lambda lets us “freeze” and then “thaw” these types of connections.

Update 4/5/2018: After running some new tests, it appears that “warm” functions now average anywhere between 4 and 20ms to connect to RDS instances in the same VPC. Cold starts still average greater than 100ms. Lambda does handle setting up DB connections really well under heavy load, but I still favor connection reuse as it cuts several milliseconds off your execution time.

Continue Reading…

How To: Install phpMyAdmin on Amazon Linux

I’ve been managing a few small MySQL databases lately that often need record updates but certainly don’t warrant building a separate management interface. The easiest way to accomplish this (assuming you don’t have complicated joins and relationships) is to install phpMyAdmin, a robust, web-based admin utility for MySQL that is built in php. In my case, I’m running these mostly on Amazon Linux instances, so after a little poking around, it turns out the installation is just 3 simple steps.

Continue Reading…