Fork me on GitHub
#babashka
<
2021-10-29
>
victorb09:10:33

Would a PR adding clojure.core.memoize`` to Babashka be of interest? Found myself needing it a couple of times now, and been manually copy-pasting the code to my projects so far

borkdude09:10:37

Let's elaborate in a Github Discussion

👍 1
borkdude21:10:11

I meant, you're welcome to create a Github Discussion for this, so we can discuss and see if more people are interested

borkdude10:10:58

babashka v0.6.4 - a fast starting Clojure scripting environment babashka https://github.com/babashka/babashka/blob/master/CHANGELOG.md#063 • Add `java.security.Provider` and `java.security.Security`. This adds compatibility with https://github.com/clj-commons/digest. • Fix mapping for `babashka.fs/unzip` https://github.com/babashka/babashka/issues/1030 • Pods: support metadata in pod vars, like docstrings (https://github.com/quoll) • babashka.curl: support `:follow-redirects false` (https://github.com/sudorock) • Add support for `--init` as a file to be loaded before evaluation actions https://github.com/babashka/babashka/issues/1033 (https://github.com/bobisageek) • Bump rewrite-clj to v1.0.699-alpha (https://github.com/yannvanhalewyn) • Fix `BABASHKA_FEATURE_POSTGRESQL` feature flag, initialize `java.sql.SQLException` build time https://github.com/babashka/babashka/issues/1040 • Deps.clj: upgrade to tools version `1.10.3.998` and include new `DEPS_CLJ_TOOLS_VERSION` environment variable to use older or newer tools jar.

👏 1
Eugen14:10:30

already upgraded 🙂

🚀 3
Krishan V17:10:39

Hey everyone, is there a pod for working with datomic?

borkdude17:10:13

Currently not, I think.

borkdude17:10:27

Datomic does support a REST API too does it?

borkdude17:10:55

Note that there is a pod for datalevin, if you're looking for a light-weight datalog-database with babashka

borkdude17:10:13

@krishanvj Ah, it seems there is a JS client for Datomic, although I'm not sure how reliable it is, but perhaps you can try it with #nbb https://www.npmjs.com/package/datomic-client-js

👀 1
Karol Wójcik19:10:10

Is the new babashka version compiled with GraalVM native-image 21.3.0?

borkdude19:10:09

why? I don't think so yet

Karol Wójcik19:10:20

I'm thinking how much babashka would shrink by the compilation with new release of GraalVM native-image. For most users this is not important, but for me is 😄 Lower binary size = lower AWS Lambda cold start

borkdude19:10:25

I have posted this before in the #graalvm channel: it shrinks with about 10mb but this 10mb is regained once you upgrade to java 17

Karol Wójcik19:10:22

Do you want to upgrade to 17? Why not to stick to 11 for now?

borkdude19:10:22

not sure yet.

borkdude19:10:55

btw lower binary size doesn't mean faster start of the binary on my local machine. why does this matter for lambda?

Karol Wójcik19:10:27

Because, before the code is executed for the first time it has to be downloaded from s3, then unpacked 😄

Karol Wójcik19:10:09

That's why I once told you the cold start for babashka is much higher than for native-compiled binary for hello world example 😄

Karol Wójcik19:10:50

It's nothing wrong with the bb itself 😄 It's just the architecture of AWS Lambda.

borkdude19:10:04

I don't think it will be a very significant difference either way, it's not more than 10-15% or so

borkdude19:10:08

@UJ1339K2B I just saw this: https://github.com/modern-energy/pulumi-cljs Could it be interesting to make this compatible with #nbb?

Karol Wójcik19:10:26

Maybe some #nbb users would like it, but frankly I used pulumi only once (same for aws-cdk) (to only show it's possible to integrate it with HL), so I dunno how much this is important.

Karol Wójcik19:10:48

I use Terraform and I'm rather against any CDK alike solutions

Karol Wójcik19:10:54

Also this looks like only a subset of pulumi.

borkdude19:10:32

you can use the pulumi nodejs library directly in nbb, no compilation required, which could be useful for this kind of scripting stuff

borkdude19:10:44

assuming that someone finds pulumi itself interesting

Karol Wójcik19:10:17

Hmm. If I were you I would not bother making it compatible with #nbb yet.

borkdude20:10:34

> which means you can now develop lambdas on M1 Hmm, don't you need graalvm m1 support for this?

borkdude20:10:45

Congrats on the release btw :)

❤️ 1
Karol Wójcik20:10:24

> Hmm, don't you need graalvm m1 support for this? Nope. 😄 GraalVM native-image already supports AMD64 linux. AWS Lambda now also support ARM64 (This is new. Like few weeks old).

Karol Wójcik20:10:51

ARM64 AWS Lambda is on linux obviously, and that's why it works.

borkdude20:10:00

then I guess I don't get the M1 reference

Karol Wójcik20:10:23

The reason M1 users were having troubles with using HL is because docker emulation is extremely slow when on M1 when using AMD64 docker images.

Karol Wójcik21:10:07

When I created HL, there was no ARM64 support for AWS Lambda, and using the emulation was the only choice.

borkdude21:10:09

oh I see :)

borkdude21:10:22

do you mean arm64?

Karol Wójcik21:10:50

Right. There was no ARM64 support.

Karol Wójcik21:10:58

isn't aarch64 == arm64?

borkdude21:10:04

oh so using arm64 docker images is faster on m1 than using amd64 images - is this what you mean?

borkdude21:10:12

yes it's the same, but I thought you made a typo

borkdude21:10:21

in amd64 -> arm64

Karol Wójcik21:10:03

It's not only faster, but also it works. Using AMD64 docker image with GraalVM on M1 tend to hang indefinitely.

borkdude21:10:38

ok, cool, all clear now

Karol Wójcik21:10:04

The new release also makes it possible to run babashka on ARM64 AWS Lambda. This is 100ms improvement in cold starts for simple hello world programs.

borkdude21:10:50

nice! btw, it is possible to trim down babashka using feature flags. there is one feature flag called BABASHKA_LEAN which leaves out most libraries, java.time, etc.

borkdude21:10:02

but then you have to compile it yourself

Karol Wójcik21:10:33

The problem with trimming it down is that you can never know what libraries one finds essential. I would have to release bunch of runtimes on AWS serverlessrepo. This is painful to mantain.

borkdude21:10:42

When you want to optimize and put in the time, that is when you go Clojure native with GraalVM I think

borkdude21:10:23

Tell this to viesti or valterri :)

borkdude21:10:34

I mean valtteri

borkdude21:10:09

I want to experiment more with this myself, but my fear about AWS is that I will do something foolish which will empty my creditcard and make me go bankrupt

😂 1
borkdude21:10:22

I wish there was some limit you could put on the money they can extract

Karol Wójcik21:10:27

See also here: https://serverlessrepo.aws.amazon.com/applications. Query for holy-lambda. All that has to be done on AWS console is to click "publish" on the pushed layer (for the first time). cc @U6N4HSMFW @U06QSF3BK

Karol Wójcik21:10:24

Hah. I can relate. I was afraid of this as well. You can set a cloudwatch rule when you cross some hard limit like (1$).

borkdude21:10:17

But what if I go to sleep and wake up to a 10k bill?

borkdude21:10:28

Cloudwatch doesn't help against this

Karol Wójcik21:10:06

The thing is that for AWS Lambda it's hard cross the free tier limit when doing either development or testing.

Karol Wójcik21:10:24

There is AWS budget or something like this, so you can specify a hard limit AFAIK.

borkdude21:10:31

I guess so. I think I used up my free tier long ago in 2014 or so

Karol Wójcik21:10:47

But AWS Lambda is lifetime free

Karol Wójcik21:10:56

for 1M of invocations per month

borkdude21:10:48

so I can crop 1M pictures a month on lambda for nothing?

Karol Wójcik21:10:40

Almost like nothing

Karol Wójcik21:10:58

Depends on what you use with Lambda

Karol Wójcik21:10:09

but yeah, regarding compute you pay nothing for invocations

borkdude21:10:13

so I think they want to make you use other services like s3, dynamodb etc right

borkdude21:10:39

and earn more money by making lambda attractive and get more users for the other services?

borkdude21:10:09

I guess I could write a lambda for a survey which stores the answers in dynamodb

borkdude21:10:55

but just making a 5$ VPS will also do the trick and limit my costs for sure

borkdude21:10:04

but I will try to do some lambda myself soon

borkdude21:10:16

hmm, what if you exposed your lambda via a route and it would get DDOS-ed? this could still cost you a lot of money I guess

Karol Wójcik06:10:42

1. All the services are protected via AWS Shield at no charge: https://aws.amazon.com/shield/ 2. Actually AWS Lambda is cheap, and most of the serverless solutions are cheap for low usage. The biggest bill you will is by using VPC Gateway for private subnets (if you're using it). What AWS wants is to make you use only AWS, hence lifetime free tiers :D

viesti06:10:20

ah neat, I had seen Luke's Pulumi cljs wrapper (https://github.com/modern-energy/pulumi-cljs) , but somehow missed the connection to nbb (nbb might not have existed that time)

viesti06:10:12

I haven't used Pulumi myself but this colleague of mine, Kari, has used and I think Pulumi is valid and neat tech, just that I tend to prefer Terraform :)

viesti06:10:40

Terraform also has CDK nowadays too, uses same magic as Cloudformation CDK

viesti06:10:09

but yeah, nbb + Pulumi would be a neat thing I think :)

Karol Wójcik09:10:52

@U04V15CAJ I think you can try HL with Datalevin + Elastic Storage. :D you would not have to learn the dynamodb :)

borkdude09:10:57

sounds good

borkdude09:10:07

babashka also supports it as a pod

Karol Wójcik13:10:41

Btw does babashka supports some kind of server for ring specification?

borkdude13:10:10

@UJ1339K2B do you mean: does babashka support a web server that can serve a ring handler?

Karol Wójcik13:10:35

Yeah. Exactly that.

borkdude13:10:43

org.httpkit.server

Karol Wójcik14:10:04

Cool. Tomorrow I will release an adapter between ring and HL. It's already used by Retailic, I have just polished it more. So you can develop locally on babashka with the ring handlers and HTTP-kit and deploy it on AWS Lambda with the single command ;D

😃 1
Karol Wójcik14:10:34

I’m also transforming real world example from polylith to AWS Lambda + Polylith. The main change is just bb.edn and reflection configs for native backend. Everything else stays mostly the same. This is extremely cool, since at any point of time you can transition back to servers if you don't like AWS Lambda.

❤️ 1
😃 1