in reply to Re: Perl microservice framework
in thread Perl microservice framework

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.

Replies are listed 'Best First'.
Re^3: Perl microservice framework
by NERDVANA (Priest) on Dec 23, 2024 at 16:04 UTC
    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?

      Well, I like the idea of having batteries included. I don't have the luxury of time to dabble with too many different options and with their respective ways of doing things (eg. I don't have time to learn both Catalyst and Mojolicious).

      Deciding on a particular stack or framework, and then switching later can be expensive. So I prefer to leverage upon the time and knowledge invested in one good thing that can [ideally] do everything.

        I think you're looking for Mojo, then. Mojo comes with its own event system, so you don't need to change anything later if you decide to do something event-driven. The toolkit all installs as a single dist, so you don't have to worry about version conflicts. Everything in the Mojolicious dist follows a common pattern for objects and minimalism. It's a very capable web framework, but also my first choice for microservices. There's also the separate Minion dist which pairs with Mojo and lets you do long background processes without disturbing the web request processing.
        Well, maybe you should have the "luxury of time" to find out what you need and what you want first?

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        see Wikisyntax for the Monastery

Re^3: Perl microservice framework
by Arunbear (Prior) on Dec 23, 2024 at 12:59 UTC