Hey guys! I’m starting with Kotlin and I’ll be usi...
# server
t
Hey guys! I’m starting with Kotlin and I’ll be using it only for server-side applications. My intention is to start using it to write serverless application, but I have some doubts about the framework to be used. I’ve worked with Java Spring Boot in the past (two years ago) and now I’m mainly working with NodeJS. My scenario is only APIs (won’t be rendering any front end). What are your thoughts on it?
o
Try #ktor
a
If you want something like node.js you can also try #vertx I've also used #http4k which I liked and it is geared towards fast startup times and works with the GraalVM as well.
👍 2
t
Thanks!! I’ll look into them. Is there a specific reason to no use spring with kotlin for aws lambda ?
t
You’re typically looking for a fast startup time with lambda. Stripping things like Spring really help.
☝️ 1
r
You could try Jooby as well.
t
Gotcha
What about #micronaut , what do you think?
r
Haven't used it, but from the docs it seems quite complicated to use with Kotlin.
🤔 2
t
From what I read “Micronaut, we are getting quite close to the barrier what is considered a microframework and what is not” But I didn’t see the docs yet
a
@thiagoretondar Spring has a very slow startup time especially within Docker. Things like #http4k are geared towards lambda (if you check the docs it is there) and it can also work on GraalVM. I mentioned #vertx because it implements the Reactor pattern just like node.js. In fact it is a multireactor where you also have the chance to run background jobs (something which node.js is incapable of). I love #spring and I use it on multiple projects but I wouldn't use it in a lambda environment because of the things I mentioned above. I can't comment on #ktor I haven't used it yet, but from what I heard it is getting mature so you might want to take a look at it as well. It is also written in Kotlin so theoretically it might be easier to use from Kotlin than other Java projects.
@Robert Jaros in my local Kotlin user group there was some talk about #micronaut on the last meetup, we had a presentation about it in fact and it seems promising, but apart from that I can't really comment on it since I haven't used it.
One more thing: if performance is important for you then you might want to check these benchmarks: https://www.techempower.com/benchmarks/
t
Perfomance is always important hahaha but I need something that can’t be hard to create and maintain I’ll check those other frameworks because not everything I’ll be running initially
Happy to know this a good community to share knowledge
d
@thiagoretondar http4k apps can be tested locally and then easily converted to run inside lambda by implementing a single wrapper interface. We don't provide any tools for upload and config because there are multiple better methods than we could write. However, what you will notice is that sizes can be made to be very small if you use a tool like proguard to shrink the binary. In our experiments, a simple hello world lambda was only 400kb in total.
👍 1
Obviously the jar size will multiply depending on complexity of the lambda, but you can be judicious in what you use for dependencies. Eg. Am pretty sure that using the in-built http client with the http4k aws module would still yield a lambda binary of less than 1mb for something taking an input request body and dumping it into S3.
t
Have you considered fronting lambda with API gateway and dumping the need to run a web server?
d
@tddmonkey can't speak for how the other libs work, but that's exactly how serverless works with http4k. Lambda is simply another backend that you plug your app into as it's completely decoupled. Then you can test locally with something like jetty (or even completely without a server and in memory), and then just upload with the wrapper.
t
just read the docs, nice
k
For AWS Lambda, you mainly care about startup times so look for frameworks that support GraalVM. I did a talk at last year's KotlinConf covering most of the available frameworks that you might want to watch. Not much has changed except micronaut has been released but I did mention it then as well because it looked so promising.
👍 1
a
Agree 100%, that's why I mentioned #http4k