Watchout! Laravel Vapor!
Tags: laravel, vapor, serverless, aws
Published: 2020-07-04 15:12:30

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](https://dev.to/themsaid/what-is-aws-lambda-and-how-laravel-vapor-uses-it-1j98) 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](https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html) 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](https://docs.vapor.build/1.0/resources/storage.html#file-uploads).
- 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](https://dev-to-uploads.s3.amazonaws.com/i/0qdm8k7vnz1obn1ykr18.png)

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](https://www.youtube.com/watch?v=xqVUdebctAM) - a great youtube overview video by Andre Madarang.

[Official Laravel Vapor Docs](https://docs.vapor.build/1.0/introduction.html) - read it even before going serverless. You'll learn a lot.

[Serverless Laravel](https://serverlesslaravelcourse.com/) - a paid course by Jack Ellis. Highly recommend this, especially if you are new in serverless world.

[DynamoDB Book](https://www.dynamodbbook.com/) - fantastic lake of knowledge. It's more for advanced users but still worth mention.