Fork me on GitHub
#graalvm
<
2022-08-30
>
rafaeldelboni12:08:14

Hi folks I hope everyone is doing great! I have a bit off-topic question, due the recent Heroku announce to drop the free tier, I'm researching a way to keep my portfolio projects running and my biggest challenge is a simple https://github.com/rafaeldelboni/super-dice-roll-clj that receives ~20 to 50 request per minute and has a Postgresql database. I saw that http://fly.io has something similar that Heroku gives in the free tier, but with half of the memory (256mb). With all that said I would like to know if any of you folks has a framework/boilerplate/example of a Clojure http service that I can compile using native-image? It need to have a routes, http client, logs, configuration manager (like aero) and database drivers, https://github.com/parenthesin/microservice-boilerplate and it work super fine, but in the project above it needs 512mb of ram to work normally 24/7 and I was hoping to get something less memory hungry with Graalvm. Yeah I know I could just pay 10 bucks a month to keep this running, but I like the challenge 😄

borkdude12:08:00

@rafaeldelboni Perhaps, if it's not too complicated, you could use #babashka or #nbb on Node.js (or compile with shadow-cljs). aero works with bb, I haven't tested with nbb. bb can easily serve hundreds of request per second. bb doesn't have postgres built-in, but this can be compiled with a feature flag or you can use the postgres pod. nbb can run any node.js library. That said, every component in bb is guaranteed to work with graalvm, else it wouldn't work in bb either.

borkdude12:08:40

Looking at your project, things that work well with graalvm are honeysql, jdbc, etc. Things that tend to bloat graalvm is clj-http, you could swap this out for clj-http-lite for example, or java-http-clj

borkdude12:08:45

yeah, those are good choices. clojure.data.json also works fine

rafaeldelboni13:08:41

something I will miss is the reitit routes and pedestal interceptors

borkdude13:08:14

you could try pedestal with graalvm too, but I haven't tried it

borkdude13:08:50

it's all just ring

borkdude13:08:22

compojure pulls in instaparse though which doesn't work that well with graalvm

borkdude13:08:47

I mean, it maybe works, but it's quite bloaty due to dynamic requires

borkdude13:08:54

or maybe I'm misremembering

borkdude13:08:06

if you want the lightest of all routers: https://github.com/askonomm/ruuter

borkdude13:08:16

that one even works in bb with httpkit

rafaeldelboni13:08:21

cool, thats looks perfect for my needs, I just need to think something for interceptors now and create a boilerplate

rafaeldelboni13:08:18

maybe this, but it looks like a bazooka for what I need https://github.com/lambda-toolshed/papillon