
Show HN: Servers.lol – Should Your EC2 Be a Lambda? - adjohn
https://servers.lol
======
superasn
A few weeks ago I created a small framework called lambdaphp[1]. The site
[https://www.lambdaphp.host/](https://www.lambdaphp.host/) is hosted on AWS
lambda only!

My aim was to host a Wordpress or Laravel site on AWS lambda without paying
any monthly hosting charges. I got everything running on it (sessions, fs,
request, etc).

Some things are different though, like when you write to a file using
_file_put_contents_ , etc it writes to a S3 bucket instead of fs (thanks to
PHP's S3 wrapper), or when you create a session, it uses AWS DynamoDB to do
that behind the scenes.

I've created some examples like this sign-in example which uses AWS Cognito +
AWS lambda to create a login/signup page[2], file uploader, etc[3].

Of course my project was just for my own amusement but I think this can be
good for side project where you just want to host something and forget about
it.

[1] [https://github.com/san-kumar/lambdaphp](https://github.com/san-
kumar/lambdaphp) [2]
[https://www.lambdaphp.host/examples/auth/](https://www.lambdaphp.host/examples/auth/)
[3] [https://github.com/san-kumar/lambdaphp#examples](https://github.com/san-
kumar/lambdaphp#examples)

~~~
RyanShook
Can you deploy a functional Wordpress blog on Lambda? Would love to try it.

~~~
superasn
I certainly hope so though I haven't tried it myself. I've managed to get the
sessions, routing, fs, etc working just fine without any additional
configuration, but of course there will be some quirks during the actual
Wordpress installation which I haven't explored yet. Maybe next week I will
try it :)

------
git-pull
Check this out:
[https://aws.amazon.com/lambda/pricing/](https://aws.amazon.com/lambda/pricing/)

> The Lambda free tier includes 1M free requests per month and 400,000 GB-
> seconds of compute time per month.

> The Lambda free tier does not automatically expire at the end of your 12
> month AWS Free Tier term, but _is available to both existing and new AWS
> customers indefinitely._

(emphasis added)

That is awesome. Providing you could get your application compatible with
lambda. This application may help for WSGI-based (python) applications:
[https://github.com/Miserlou/Zappa](https://github.com/Miserlou/Zappa)

More on AWS Lambda:
[https://aws.amazon.com/lambda/](https://aws.amazon.com/lambda/)

~~~
Mizza
Zappa isn't just for WSGI, you can also build massively parallel event driven
applications with async task invocation!

[https://github.com/Miserlou/Zappa#asynchronous-task-
executio...](https://github.com/Miserlou/Zappa#asynchronous-task-execution)

:D

------
ghostly_s
I'm sure it's quite obvious to those who work intimately with Amazon services,
but for the rest of us, and because it's un-googlable, this apparently is
referring to a specific service, AWS Lambda. Would be helpful to include any
explanation at all on the landing page.

~~~
adjohn
Point well taken, we'll iterate on this and add some background on Lambda.

------
inscrutable
I watched the overview video below and the tldr for me is that although
serverless is doable now and can be done well, the tooling is not there yet,
and you're also locked into AWS. So check back in back in 2-3 years.

For me, I think Kubernetes + virtual kubelet (for container instance creation,
with per second billing, only on Azure right now) is the safest option. It
gives the benefit of easily scalable compute with no need to move to an event
driven model or constraints on function duration and resource usage.

[https://www.youtube.com/watch?v=1fBbSgJJV_g](https://www.youtube.com/watch?v=1fBbSgJJV_g)

[https://github.com/virtual-kubelet/virtual-
kubelet](https://github.com/virtual-kubelet/virtual-kubelet)

~~~
illumin8
You can do the same thing (just run a horizontally scalable container for me
with per-second billing) on AWS Fargate:
[https://aws.amazon.com/fargate/](https://aws.amazon.com/fargate/)

It will also support Kubernetes pods next year.

Disclaimer: I work for AWS.

~~~
IanCal
What's the startup time like with fargate? Is it in the region of a few
seconds, or is it more like minutes?

~~~
iampims
I’ve read reports of fargate startup times around 45s. Not fast, but not
terribly slow either.

~~~
IanCal
Thanks, that really helps place it in terms of where it might fit with my
workflow.

------
jasonkester
Nice calculator, but it's missing an important field: How many hours per day
do you keep your machines running. It assumes you run 24/7.

S3stat's nightly job needs 60 or 70 hours to run, but it all has to happen in
the few hours after Amazon finishes delivering logfiles for the day. So I spin
up 15 or so machines as spot instances that churn through the queue then shut
down.

This calculator tells me that should cost $600 or so per day, when reality it
is more like $12. So even though it claims Lambda could do the same thing for
$5, it'd take a long time to win back the engineering cost of making the
switch. (A little over a month for every hour I spent working on it, it
seems).

~~~
shubb
One of the big value propositions of the cloud was to automatically provision
extra servers in response to load - either like you are doing, or by detecting
load spikes and spinning up instances.

Trouble is, people don't seem to do that. I see a lot of 'Boss says use the
cloud, lets just provision our current network in AWS 24/7'.

I kind of see serverless abd redshift as a workaround for the fact that users
are currently mostly doing it wrong, and will eventually figure out that an
always on cloud deployment is more expensive than just hiring server or colo.

------
SideburnsOfDoom
What it doesn't mention is the high latency of the 99th percentile of
requests. If that's something that you don't want, then avoid Lambda, for now.

~~~
javadocmd
Is the high latency you mention due entirely to cold starting instances, or is
there another cause?

~~~
kenoyer130
We had huge problems with Java and Lambda start up times. I would strongly
recommend python/nodejs or maybe Go. For whatever reason .Net core was still
slower but not Java holy crap slow.

------
brango
The thing that makes me nervous about Lambda is the lack of price capping to
prevent buggy functions racking up thousands of dollars in a weekend.

~~~
Cthulhu_
That's where you apply some software developer diligence and do proper testing
and monitoring. You're saying right now that regular servers / instances allow
developers to be lazy because hey, automatic caps.

~~~
brango
Everyone makes mistakes. If a dev deploys something to a server with fixed
costs that starts hammering CPU at least we won't be hit by literally
thousands of dollars in extra charges.

------
keyboardhitter
Wonderful website! Really appreciate the detail put into this. And it worked
very smoothly on mobile.

Indeed, lambdas are worth considering for some but not all projects, and this
tool seems helpful for people who may need a place to start researching their
options.

------
lotyrin
This claims that on close-to-breakeven applications that moving to serverless
might reduce dev costs or accelerate dev work... Serverless proponents: how
does that work in theory?

In practice, all the serverless guys I've seen have a pre-CI pre-VCS pre-UAT
kind of workflow using the AWS console where there's no change control or
ability to collaborate.

~~~
agranias
Of course it depends on the use case, but for smaller functions it definitely
reduces dev work. For AWS, Lambdas can be versioned and aliased. Blue green
deployments are trivial since you can switch Lambda versions on the fly.
Rolling back and invoking dev versions are similar.

~~~
illumin8
You can now even do canary deployments where you switch a small amount of
traffic to a new version of your Lambda. The FaaS (function as a service)
ecosystem is rapidly reaching parity with traditional software.

Disclaimer: I work for AWS

------
fastest963
It's unclear if the Requests/minute is per instance or total. I tried putting
in 500k/minute (total) and got a $40k Lambda bill vs $2k EC2 bill (which is
roughly what we pay). If I switch it to 20k/minute (per instance) then it's
more-or-less the same price for either.

~~~
jopsen
I get the feeling that lambda is only good for small apps..

Once request volume goes up, instances are much cheaper.

So lambda makes sense for hobby stuff and those small services that you only
use occasionally. And then again, the financial motivation probably have more
to do with maintenance cost.

~~~
IanCal
It can be good for very bursty things too, particularly in the background. I
process 'lots' of json on S3 using it. With no setup or anything complex I can
churn through a a TB of json in a few minutes. Not sure on total time, but
it's less time than it take me to sync the resulting files to my local
machine. Running a thousand things at once for a few minutes is great.

------
donatj
According to this our app would be $44k in lambda and $2k in EC2.

I suspect we’re paying a great deal more than that for EC2 but I don’t see
those bills.

------
upbeatlinux
serverless is the shake weight of tech.

in all seriousness a very useful and cool tool. thanks for sharing!

i'd have picked a more informative domain; maybe serverless.info?

nice to know that is currently not cost effective for my workload.

\- lambda = $3,327.05

\- ec2 = $1,1146.24

~~~
jjeaff
Serverless is great for all the tiny little things I want to schedule and
forget or setup a trigger for and forget. But my type of usage is not going to
pay the bills for serverless.

I just don't get why anyone is using stuff like lambda for big projects unless
they have extremely unpredictable and extremely spikey traffic.

Because any kind of sustained usage will quickly be cheaper to put on a nano
instance and scale up from there.

------
marcell
The main disadvantage of serverless though is the need to learn an entirely
new tech stack, and one that is locked in to AWS. Migrating a large (or medium
sized) Django app to Lambda has non-trivial cost in terms of engineering time.
Also the Lambda stack is less well known, which may cause some challenges for
the engineering team (ramp-up time for new hires, etc.)

~~~
tjbiddle
Eh - I wouldn't say an _entirely new_ tech stack. The main difference is
breaking your components into microservices; after that - you just need a
wrapper for your serverless provider of choice. The majority of the logic
should be reusable though.

------
djhworld
This is great, I wanted to make something like this once but never got round
to it.

Mainly because the pricing calculator from AWS is pure trash

------
hueving
I'm curious, is there an intersection of people who make significant use of
AWS who purport to support the open source movement? If so, how do you
reconcile centralizing so much of your business/personal data and technology
influence behind such a proprietary platform?

~~~
oconnore
I upload my code to AWS, and it gets run.

You save your code to your Intel laptop, and it gets run.

Neither of us have the complete source code that is used to run that code. You
have to be ok with that, and drawing a line in the sand at the hypervisor
level just seems super arbitrary.

~~~
javajosh
i can buy an amd laptop and run my code. where you gonna run your aws
architected code if aws changes their policies to something you don't like?
hint: it's called vendor lock-in.

~~~
oconnore
Ok, so then I spend 5 minutes changing some boilerplate and upload it to
Azure/Google Cloud/a server I bought on craigslist? Even if that did happen, I
probably would still have saved time overall, because I didn't have to
maintain physical infrastructure between now and whenever that distasteful
policy change takes place.

~~~
javajosh
nope. if your code takes 5 minutes to rewrite, then who cares? if it takes
longer, then you have a big, expensive, risky problem.

~~~
PetahNZ
Its not the code that take 5 minutes to rewrite, its the AWS entry point.

~~~
javajosh
I call bullshit. But if you want to do the experiment, on video, I'll watch
it.

------
draegtun
You can even get Pharo to run on AWS Lambda -
[https://gitlab.com/macta/PharoLambda](https://gitlab.com/macta/PharoLambda)

However what's really interesting is that it serialises any crash to S3 which
you can then pull down and run/fix in your local Pharo debugger -
[https://twitter.com/martinfowler/status/897083875003969536?l...](https://twitter.com/martinfowler/status/897083875003969536?lang=en-
gb)

------
stephengillie
If Lambda supported Powershell, I'd already have moved hundreds of small
Active Directory management scripts there.

And I'd move at least a couple personal projects there, instead of porting
them to Node.

I know I'm in the minority, but there are dozens of us.

~~~
ewindisch
On AWS Lambda you could copy the Powershell Linux binary into your project and
call it from wrapper code in NodeJS, Python, Java, C#, or Go.

Over in Microsoft land, Azure Functions natively supports Powershell according
to this blog post: [https://david-obrien.net/2016/07/azure-functions-
PowerShell/](https://david-obrien.net/2016/07/azure-functions-PowerShell/)

------
fastfiveoh
I see some systems that might be prime for the move, thanks!

------
askvictor
Is there any work emerging on a standard environment/framework for serverless
code? As it stands it all represents vendor-lock-in due to the comparatively
high costs of moving between stacks. An environment that's deployable to any
of the serverless providers would be ideal.

~~~
lbrindze
I believe serverless works on a bunch of different providers. I have no
affiliation with this project but it’s a pretty good tool!
[https://serverless.com/](https://serverless.com/)

------
jack9
> perhaps its time to ponder if a more modern architecture would save you
> money or positively affect developer experience.

That's condescending and inappropriate (since it knows nothing about
"modernity" in architecture), at the same time.

------
RileyJames
Nice. No feedback. But the share link at the end is just the root domain:
[https://imgur.com/gallery/FL0xa](https://imgur.com/gallery/FL0xa)

~~~
eganist
I'd venture the "without results" caveat just above that link might be why.

------
covermydonkey
Perhaps you could factor in something about cold-start?

I know that in my context, this has been a key issue. Another odd one is that
our organization has only certified RHEL and Cent OS running server-side code.

~~~
illumin8
What exactly are your issues with cold start? This typically only affects
functions that are called a few times a day, and can be solved for those
functions by running a CloudWatch event that triggers your function every few
minutes or so. You get 1 million free invocations a month, so this typically
doesn't increase your bill.

Disclaimer: I work for AWS

------
tinus_hn
I’m not sure what the stated purpose is for the .lol tld but it is difficult
to take a service seriously when it uses a domain like servers.lol

------
sgallant
Wow, we're paying A LOT more than we need to.

~~~
klinskyc
Would Lambda work for On-Prem at all?

~~~
illumin8
Yes, take a look at AWS Greengrass:
[https://aws.amazon.com/greengrass/](https://aws.amazon.com/greengrass/)

This lets you run the same Lambda execution environment on any device you own.
Typically, we see this being used by customers that need to do computing at
the edge where Internet connectivity is poor or intermittent (think oil and
gas fields, mines, etc.)

Disclaimer: I work for AWS

------
stephen123
Fun site! It's a bit annoying that you can't edit the input and get a new
result though.

~~~
adjohn
Thanks for the feedback! You should be able to edit the inputs by clicking on
the left hand side (application name) to change the inputs above.

------
aetherspawn
Nice to see Haskell on the list.

~~~
lgas
It's in the list but when you click on it, it says "Some of the languages you
are using are not yet officially supported in Lambda, but there are still
runtime workarounds. Here are some resources:" and links to a blog post about
running Haskell on Lambda.

