loading...
Cover image for Watchout! Laravel Vapor!

Watchout! Laravel Vapor!

abandonedsign profile image Evil Commissar ・4 min read

Hi there 👋

TL;DR: The goal of this post is not to blame. I'd like to share my view and experience after a few months of using Laravel Vapor. Maybe, my monolog will be processed by the Laravel team and some of my "pain points" could be converted to backlog items. Also, at the end of this post, I'll share some good learning resources.

Foreword

I assume that the reader of this post has at least general knowledge about aws/serverless/laravel/vapor. This is not an introduction to a serverless world either laravel. Just in case, you can read a great overview of aws lambda by Mohamed Said if you're interested in such content.

Motivation

Today in the morning I've received a push notification from my mobile bank app. AWS just charged my account by 50$. It's a really huge price only in one case - empty account. I knew that currently - I'm not using any of the services. Surprise!
That's why this post should be here. Maybe, it will help someone better understand the tools they are using.

Project Types

I would say that not all projects are suitable for serverless. Deal with it. There is no need to prove that you can host your e-shop using Lambda! Yes, you can of course, but instead of benefits, you'll get bottlenecks in different places.

Mostly because of limits. Always keep in mind Lamda's limitation before going serverless!

The most important things that need to be considered in the case of migration classical app to serverless:

  • File Uploads. (Yes, all existing uploads should be rewritten via different approach.
  • Headers size. That's very strange but for some reason, headers have limited size than can be easily reached. For example, if you prefer storing JWT token in cookies and transfer it via HTTP - you might not guess the final size and make your site unavailable for visitors. Just by setting cookies.
  • Background jobs. They are different a bit. Again, because of limits. I saw folks usually go for 5$ droplet on the digital ocean for horizon/laravel/jobs worker setup.
  • You need skilled developers. Things can go wrong very easily. Something can be configured wrong and you will spend a lot of money because of the serverless charging model.

Price

I wish Laravel Vapor will be closer to the developers. Like the digital ocean does. Yes, of course, for mid/big size teams it's a fair price. But for standalone developers, it is too much.

I understand the reasons. But cannot understand why there is no 10$ "hack" plan for those who don't need support and who can live even with 1-2 deployments per day.

I think this will definitely popularize serverless among developers. And Vapor will grow in popularity too. But we have what we have.

So, what about 50$?

Laravel Vapor doesn't care about the resources that he created.
And in my opinion, there are should be multiple notices about this (at least somewhere during registration or on the dashboard or when you deleting stuff).

There is no way to monitor the state properly (something like Terraform does). After changing some settings on AWS - that settings will not be reflected on your Vapor account and vice versa. That is a big disadvantage. In my case, the root cause was simple:

  1. I've canceled my Vapor subscription.
  2. Disabled and removed everything from Vapor (even access to AWS account).
  3. Thought I'm done with my playground projects and can easily close the browser.

I was wrong. All CloudWatch events were in the AWS account as well as lambda functions and other stuff that Vapor created for project needs.

And because on of my different project removed bucket where was vendor folder with all project dependencies - functions got these errors in an infinite loop.

error log

Basically, I paid my invoice for error invocations because of that :D

Final words

Will something change with the Laravel Vapor pricing model in the near future? No. Simple developers aren't a focus group. No one cares about them, because there will be always teams who can easily pay 39$ per month. And that's normal and understandable.

Last but not least - Thank you guys from the Laravel team!
I have fun during my 3-month journey with laravel Vapor & serverless in general. UI/UX very simple and intuitive.
Support also is very nice, polite, and responsible.

I wish luck with this great product.

Resources

Laravel Vapor Overview - a great youtube overview video by Andre Madarang.

Official Laravel Vapor Docs - read it even before going serverless. You'll learn a lot.

Serverless Laravel - a paid course by Jack Ellis. Highly recommend this, especially if you are new in serverless world.

DynamoDB Book - fantastic lake of knowledge. It's more for advanced users but still worth mention.

Discussion

markdown guide
 

I was just linked to this post on Twitter. For anyone reading this who wants a review of how Vapor performs when you use it properly & don't write infinite loops, here's my review: usefathom.com/blog/vapor-one-year

 

Please, read the whole post. Not only the title.
I didn't write an infinity loop.

The root cause of this situation was the fact that after canceling my subscription on Vapor (and deleting everything from it) - he gives me the illusion that everything is fine and clean. In fact - it doesn't, because all resources were still on the AWS account. And if you (or your other project code) accidentally will remove s3 bucket - this will cause infinity lambda invocation and you'll pay for that.

I'm happy that you know how to use it "properly", really. I don't.
Even after spending hours on comprehensive documentation and "Serverless Laravel" course.

People should know pitfalls. Especially, newbies who just started learning serverless and decided to go with Vapor, that's it.

 

For sure. What can I add to the Serverless Laravel course to prevent this? I've not heard of anyone deleting S3s and obviously I don't want this to happen to anyone else. Was the infinite loop the only issue you experienced?

Yes. Only one issue...

And don't get my wrong, I will continue to use Vapor soon.
This cannot stop me from using it ^^

Personally, I see two options here:

  1. You could add a short video/notice about configuring billing alerts/budgets on AWS. If this will be lesson 0 in course series - it will prevent such situation, I think. Because all experiments will be controlled from the beginning.

  2. Communicate somehow with Laravel team, and put some additional notices before deleting projects and inform the user that he needs to remove everything from AWS manually (and give information what should be removed)

Something like this!

Thank you for understanding me, Jack!
And a big thanks for all your work! ❤️

I didn’t realize you had taken my course when replying to you originally. That means I have more work to do here. So I apologize for jumping the gun.

I’ll take this and see what I can do.