https://kotlinlang.org logo
#ktor
Title
# ktor
j

Júlio Santos

12/07/2021, 7:10 PM
Talk about guys! Do you happen to have any material on the differences between Spring and Ktor? Please
c

Casey Brooks

12/07/2021, 7:36 PM
Might be easier to ask for what's the same between the two 😂 Similarities: HTTP Differences: Literally everything else
1
Spring represents much of the "enterprise architecture" for a webserver. It's old, mature, stable, and very feature-rich. But it's a Java framework, which heavily leverages "magic" through annotation processing. But it has strong conventions, making one project by-and-large the same as any other when it comes to the actual HTTP stuff
In contrast Ktor is much more of a "microservice" architecture. It's smaller, lighter, and less bogged-down with legacy Java code, but also has less features. It puts the control and design of your web application into your hands, rather than having everything templated out, which gives more flexibility, but also less consistency overall from project-to-project
j

Júlio Santos

12/07/2021, 7:49 PM
I understand @Casey Brooks, I think so too, because I have been working with Ktor for 2 years
With this amount of time in use, I have some questions like, is its startup time with Spring very different? Is the monitoring issue flexible with Spring? Honestly, I like Ktor a lot, especially for the coroutines
c

Casey Brooks

12/07/2021, 8:02 PM
I don't have anything concrete here as I haven't professionally developed with either (I mostly do native Android, but have used both for side projects and learning exercises). Ktor definitely seems to have a much faster startup out-of-the-box, but you can tune Spring to exclude features you don't need to improve startup times (https://dev.to/bufferings/lets-make-springboot-app-start-faster-k9m). Startup time is relevant to DevOps teams for minimizing downtime, but not so much for end-users. I really don't know which one is better for runtime performance. You'll almost certainly have better monitoring with Spring, as all the big APMs should have really good Spring integrations due to its maturity, but Ktor has plugins for setting up metrics though it will probably be a more manual process
j

Júlio Santos

12/07/2021, 8:04 PM
We did a comparison between both where I work, the difference was small! But I didn't know about these plugins! Thanks a lot, I'll look into it
c

Casey Brooks

12/07/2021, 8:05 PM
I think a lot of the startup time for ktor is dependent on the HTTP engine you're using. For example, I think Netty and CIO have faster startup times than Jetty or Tomcat, but I really don't know enough about the differences between all those to know which one is actually the best
j

Júlio Santos

12/07/2021, 8:34 PM
Yes, we've seen this in testing, but it's not something like Micronaut, for now Ktor offers a freedom that Spring doesn't in the sense of building components, going back to the architecture of the project.