Re: Perl microservice framework
by NERDVANA (Priest) on Dec 23, 2024 at 05:43 UTC
|
Can you describe the features of Springboot that you find valuable when developing a microservice?
If you are just looking for the easiest way to write a web service in Perl, Mojolicious::Lite lets you define the whole thing in a single file, and the Mojolicious dist comes with all the tools you need to write event-driven perl code. Those event-driven tools also make a good foundation for non-web services that talk on a TCP or Unix socket.
There is also the Plack ecosystem, which is designed to glue together Servers, Middleware, and Applications. If your microservice is simple enough, you can write it as a Plack app and not even need a fancier web framework. You would write a file with a single sub($env) { ... } in it, (where $env contains the PSGI environment describing the HTTP request) and then run it behind a server of your choice like Gazelle or Twiggy using the "plackup" command.
Aside from that, I don't have experience with Spring or Springboot to know what you might be expecting to find in a framework. | [reply] [d/l] |
|
|
I suppose I could use Mojolicious/lite for REST, but Mojolicious is typically associated with web frameworks.
Therefore I was wondering if there was a leading microservice framework for Perl that has mainstream community support.
I would prefer not to cobble bits and pieces of disparate Perl technologies to build a microservice architecture.
| [reply] |
|
|
I'm going to go out on a limb and guess that Mojolicious is lighter-weight (from the coding perspective) than anything that has ever been developed in Java. You can literally write the entire app in a single file, with nice descriptive REST URLs. You don't even need any directory structure.
Here's an example Mojo app that serves a Powerpoint/Keynote-like experience (including navigating the slides from a device the presenter is holding) out of a single HTML file that you pair with the controller.
Here's another single-file app (aside from served assets) that implements a multiplayer Asteroids game, currently hosted live at https://nrdvana.net/asteroids/. I showed that off for my presentation back in 2019 and then it uses so little resources I never bothered to turn it off. It uses 12MB of RAM currently, and lives in a docker container. (I also never bothered to finish it, as there are currently no asteroids or collision detection, heh. It's just a tech-demo of websockets)
Java has a strong need for "lighter weight" because their default framework stance is "500 layers of abstraction". I see Springboot's home page advertising "you don't even need any XML" and it made me chuckle. I did quite a lot of Java in college, and eventually grew to hate it because while the structure of the type system felt nice, it takes forever to get anything done, and you have to learn about each of those layers of abstraction. It would not surprise me if Catalyst (perl's heaviest web framework) was lighter to develop with than Spring. (again, I have no experience with Spring. Tomcat+Servlets were the lightest option at the time I stopped using Java)
It all comes down to what you want the framework to accomplish for you. Catalyst is a structured framework like Ruby on Rails, and by default comes with a directory layout and a config file (but you can technically still do single-file apps with it). Dancer and Mojo are lighter than that, and let you opt-out of most of the extras. Mojo is special in that it was designed for event-driven code, so you can have a single perl process serving lots of clients instead of a giant pool of Perl processes. It also has the event-friendly database drivers like Mojo::Pg. Plack is so light you can barely call it a framework. Whatever level of "lightweight" you want, Perl has it. But then you finish with "I would prefer not to cobble bits and pieces of disparate Perl technologies to build a microservice architecture" ... but then we come right back to the question: what do you expect the microservice architecture to accomplish for you? And if *more* features are your goal, then why are you averse to a normal web framework?
| [reply] |
|
|
|
|
|
|
|
|
|
| [reply] |
Re: Perl microservice framework
by InfiniteSilence (Curate) on Dec 23, 2024 at 07:52 UTC
|
Functionally a microservice is going to resemble an end point that one could easily build with Dancer, for instance, but to quote IBM: "...given the massive increase in complexity, moving parts and dependencies that come with microservices, it would be unwise to approach microservices without significant investments in deployment, monitoring and lifecycle automation..."
For the issues depicted above I think you might want to take a look at Myriad on CPAN which looks like it addresses them.
Celebrate Intellectual Diversity
| [reply] |
Re: Perl microservice framework
by etj (Priest) on Dec 23, 2024 at 14:48 UTC
|
I think the IBM point about complexity and getting deployment right is a good one.
My suggestion would be to use GraphQL, and Mojolicious. | [reply] |