Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring boot jar on azure websites performance issues

I have an application built as a spring boot fat jar. I host it in azure websites according to "official" documentation with a web.config similar too:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <handlers>
            <add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
        </handlers>
        <httpPlatform processPath="%JAVA_HOME%\bin\java.exe" arguments="-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar &quot;%HOME%\site\wwwroot\my-web-project.jar&quot;">
        </httpPlatform>
    </system.webServer>
</configuration>

The application is monolithic in structure, not too large but does some mapping and has some layers to initialize so startup time is about 12 seconds locally. It runs an H2 in memory database just for testing purposes.

Actual deployment and getting it running on azure websites were never really a problem, but there's some real performance issues, at least with the settings I have.

Some settings of interest:

  • Standard S1 instance (at the time of writing costing about ~$40USD/month).
  • Webapp configured with:
    • Tomcat8 (shouldn't really matter as the fat jar runs embedded tomcat)
    • JDK 8
    • Always on enabled

To be able to compare the numbers to something I ran the application on an Azure VM I have with similar (but not the same) specs and price range and ran the application on that one.

Here are some of the results:

Startup time of the application:

  • Azure websites: ~2 minutes
  • VM: 30 sek

Cold call:

Deployed/started the application and left it to make a call the day after.

  • Azure websites: 31119 ms
  • VM: 219 ms

Consequent call:

A call directly after the cold call, but to another endpoint.

  • Azure websites: 2685 ms
  • VM: 223 ms

My question here is: Do any one know if it is viable to run spring boot fat jars hosted on azure websites? As there is official documentation from Microsoft one would think that it is, and of course technically it is, but is it viable in production?

I'm not really after any debating about AWS vs Azure vs Google App Engine ....., or to write wars/jars or how to host it.

I have reasons to want it this way. If it's not possible I have other options but would like to explore the idea first and see if any one else has better experiences?

Edit: Just to add to the information. The database was empty for all calls. So that shouldn't add any overhead to speak off. No data was actually fetched only empty lists.

like image 750
alefr Avatar asked Nov 08 '22 06:11

alefr


1 Answers

Although it is an old question and my answer is rather not valuable since I have no knowledge on Azure, but I would like to share results of my research. I have couple of Spring Boot microservices and one relatively big service (170 MB fat jar that on my local machine starts in about 70 seconds). Azure starts small microservices in tens (if not in hundreds) of seconds... and I mean like really small microservices (an example of config server from Spring Cloud etc... there is nothing fancy going on there). If it comes to the big one - Azure starts it and after 2 minutes... starts it again... and again... and again. As a result it never gets started.

and it was all on B3 app service plan. So quite big plan.

Wrapping up, in my (strongly subjective) opinion - Azure is not a viable option for Java apps.

like image 195
Piotr Tempes Avatar answered Nov 30 '22 04:11

Piotr Tempes