May be a dumb question, but what makes the Ktor `e...
# ktor
j
May be a dumb question, but what makes the Ktor
embeddedServer
embedded?
e
https://ktor.io/docs/create-server.html server is embedded in your application, as opposed to the common pattern (at least in the Java world) of loading your application into a servlet container
j
So an instance of the server is running alongside the client application? And is the communication between application and server network-less? For context, I have a KMP mobile app accessing my Ktor server. Thanks
c
I’m not traditionally a Java developer, so take my explaination with a grain of salt. But I do believe this is how things generally work from my time toying around with Ktor and understanding the Java ecosystem: Most Java “application servers” use the Servlet protocol to enable one to run HTTP servers. Basically, this means that you start a process with the Java application server (Netty, Jetty, etc) and then your server artifact gets loaded dynamically by the classloader of that application server. You typically bundle a “fat jar” (a single JAR or WAR file) with all your own server’s dependencies, but not depending on any particular server implementation. So the application server loads up your fat jar and starts communicating with it in-process via the Servlet protocol (or something similar to that) to forward HTTP requests to your application, where they are actually handled. So the process of an application server actually serving your own site’s content does not requlre an external network connection, so it’s all very quick, but it does potentially open up issues with classloaders (though you probably don’t need to worry about this)
So an “embedded server” includes the entirety Netty/Jetty/etc in your own server’s dependencies so you don’t need that external application server, thus including them in the final “fat jar” for your application rather than letting it be loaded into the application server load your code dynamically
j
Sounds similar to Spring, where tomcat + server stuff is included in the main application as dependencies and thus doesn't have to be run in its own container? I ask the original question because I use an embedded database, Realm, as a Repository in the Ktor, which wouldn't make much sense on a standalone server, but if it's packaged with the client application that doesn't sound too bad.