I have an application running on a JBoss server. We need update the application time to time.
However, the JBoss is not allowed stop(restart) during update for business reason. How do I handle this tricky situation? Thanks!
2 cases:
If the application is deployed in
multi servers in cluster mode.
If the application is deployed in a
single machine.
If you can't stop the application even for a moment then you probably need to:
To run both versions at the same time.
Direct new users to the new version and allow existing user sessions to continue against the old version
To be able to detect that the old version is no longer in use and hence can be stopped.
Each of the above is, in principle, possible but specifics of the applcations can present serious obstacles.
Many organisations simply take the view that there can be a small hiatus in service, for example at 2:00 AM on a Sunday morning. They warn users "system going down", then stop the old version and start the new. This is much simpler than providing 100% up-time.
One trick with this approach is that it may be possible (I know it can be done in WebSphere, don't know about JBOSS) to deply the new version of the app but not activate it. When an app takes several minutes to deploy and start this can shorten the down time.
It's a common problem, and web apps can't really "updated" at runtime (unless it's a hotdeploy environment). Perhaps you want something like LiveRebel?
LiveRebel
Would you like to update your
application in production with zero
downtime? Avoid the tedious and
error-prone application update
roll-outs? Roll back unsuccessful
updates with a press of a button? Then
sign up to receive an invitation as
soon as it’s available.
Related
Context: I am learning to code with a course run by my country's government. We are using Angular, Java Spring Boot and SQL to create a portfolio. They did not go into much detail on different things, and they pointed us to Google (and Stack Overflow), as well as cooperation between students, for any doubts. I managed to create an app, and is currently hosted on Firebase (frontend), Heroku (backend) and CleverCloud (database), with the free versions of each.
When running the app locally, it starts in around 10 seconds. When running the app in Heroku or doing clean and build in Apache Netbeans while connected to CleverCloud, it starts in around 2 minutes. I would like to reduce the start up as much as possible. The obvious solution would probably be to use a non free version of Heroku and not let the app stop, but given both my country and the course aiming for the free version, that is not an option.
What I tried:
Deleting unused imports on entities and adding the "Excluding test
dependencies" part in this Heroku guide:
https://devcenter.heroku.com/articles/reducing-the-slug-size-of-java-applications,
but after doing a clean and build in Apache Netbeans, the load time
was around 2 minutes, and it took like another minute to do other
processes that were not there before. I ended rolling back the changes.
Added a loading screen to the frontend to tell users that Heroku takes 2 minutes on startup, and a timeout of like 1800000 on the HTTP calls made from the frontend, but the HTTP call still crashes after like a minute, making it so user have to refresh the page and wait.
I would like, as the app is going to be checked at some point, to either have the app running nonstop on weekdays on workhours or for it to start fast. I saw some pages like https://kaffeine.herokuapp.com/ that ping the app, yet I dont know how to use them o if I can set them for free to be used on weekdays and workhours.
Given the startup is slow on both Heroku and while doing a clean and build in Apache Netbeans while connecting to CleverCloud, I dont even know if the issue is on Heroku itself. As someone who is completely new to coding, and its exposure has been a "do this" without much explanation, this is kinda frustrating. I have seen something called "cron", but I dont understand how they work or to create them, or if they would work on a Java app that only supports CRUD (maybe doing this cron thing on the frontend, but still I dont know anything about them).
TLDR: Are there any ways to speed up the build or start up of a Java app, or guides to autoping free Heroku apps on weekdays and workhours for dummies?
Sorry if the question is obvious, as I am a total beginner that had to rely on code along guides and videos.
For the Free & Hobby version on Heroku you application on Free version will go to sleep which after arriving on the site will take a while to load up.
Sleeps after 30 mins of inactivity, otherwise always on depending on your remaining monthly free dyno hours.
For 7 bucks a month you can remove this restriction and get more power Hobby version - I think it's totally worth it and I use this for my personal projects quite a lot. https://www.heroku.com/pricing
If you use something to ping Heroku to keep it alive you will run out of dyno hours (hours that your app can run) and even then the free tier will have hard time running applications.
Also Heroku supports SQL (Postgres) so having db, frontend and backend in the same place is a bonus. Everything runs smoothly, environment variables and automatic deploys are easy to set up.
If it's your first time on AWS you could also use free tier over there for some time and deploy using elastic beanstalk. But AWS infrastructure can be overwhelming for one simple free project - gotta watch out when they start charging you.
I've just recently entered the Java world for a client of mine. I have 18 years experience as a .Net developer, but the Java side is new.
Coming from .Net, I'm used to expecting to be able to make a code change, compile my code and run it with a debugger attached all usually within sub 30 seconds, maybe 1 minute on large projects needing a full recompile.
I'm finding my current process with this Java project is taking me upwards of 5-6 minutes. Because of the long time and multiple steps, I find myself starting on other tasks or losing track of what I was doing.
Here is my current process for making a change and testing it:
Make code change
(~200s) Recompile code with Maven on the main Maven module mvn clean install. If I do -DskipTests I can save about 60 seconds here.
(~5s) Stop Wildfly server
(~5s) Copy .war file from myproject\target\myproject.war to c:\wildfly\standalone\deploy\
(~90s) Start Wildfly server c:\wildfly\bin\standalone.bat
Re-login to application (my session expired)
Attach debugger
Again, it is not only the amount of time required for each of these steps but the fact that there are so many steps and the waiting time in-between each makes for distraction as well - after all, who is going to sit and stare at a screen for a 3 minute compile? Whatever I go off to do, I am surely not going to return to that screen at the exact moment the compile is complete. There is going to be wasted time in there.
Further more, I'm repeating this process every time I want to make a single code change.
Is there a way to streamline this process? I.e.:
Is there a way to join some of these steps
Can I speed up the Wildfly boot process?
What will speed Maven up?
Can I do something like "Edit & Continue" which exists in .Net (i.e. live code changes).
Is there a way to get around having to have Wildfly reinitialize anytime I deploy a new war?
Disclaimer: My answer includes processes I personally use, thus it may not be the optimum or most popular solution. Anyway, these things tend to be bound to developer's personal preference.
Find below some recommendations that could speed up the development process.
Use a proper IDE for Java development
Using a popular java IDE can make development faster as it supports integration with build tools(Maven), Version Control Systems, Application Servers(Wildfly) and much more.
Popular choices are Eclipse, IntelliJ, Netbeans and much more.
Fast redeployment
As I said above, a proper IDE would support integration with application servers, Wildfly for your case. By using a Wildfly IDE plugin, you can speed things up as you do not have to wait for app server to boot every time you make a code change. IDE starts once the server and then applies your changes to the running instance.
Personally, I also prefer to use a standalone Wildfly installation instead of integrating it with IDE. To achieve fast redeployment I use hotswap agent. Note that you have to install DCEVM, an alternate JVM which however is not interfering with your main JVM.
Finally, to conclude it is understandable that you make a big turn from .NET to Java and you may feel lost at some points. I would advise to spend some time setting up your environment, and once you have finalised it and you feel comfortable, development will become much easier.
Why stop, move the archive and re-start the server ?
Check out the following maven plugin which will allow you to automate at least that part of it..
https://docs.jboss.org/wildfly/plugins/maven/latest/examples/deployment-example.html
We use Eclipse to develop and Websphere 7.0 to run our code. We use a plugin for Eclipse which allows you run run a copy of WAS locally and integrated with Eclipse. This works but it's not great. Each time I have to make a change I have to run my Ant script (5 mins.) then do my install into WAS and restart the app in WAS (another 5 mins). This is not efficient (actually it's downright annoying!)
What's the best setup Websphere allows, ignoring for a min what is easy to do etc. I want to know what to aim for. Obviously I would love to be able to save in eclipse then go to my browser and refresh the screen, am I mad?
I have looked at this about using Websphere's native Ant, and it is one avenue but I'm sure there's better.
Can I use jpda like I do when starting Tomcat and develop directly in the code? I will still need Ant when doing a full re-build as I have some Java file generation to do but for the in-process builds???
Thanks-in-advance for any and all help.
There is not just one straightforward single best answer as it depends a lot on the application you are doing.
If you rely on ant to make the build and that takes five minutes for any update you do then it may be hard to get away from that. You may not have to do it like that, you may be able to do incremental compilations (only compiling the updated classes) and that should be a lot quicker (but since I don't know anything about your application it is hard for me to tell you that this is a way forward for you). The updates you make in WAS and if that requires a total restart of the application depends on many different factors.
If I update only a jsp file it usually does not require a full application restart, but if you start to update the classes and definitely when you update your web.xml or something like that, a full restart of the application may be required.
The time it takes for you to restart your application depends a lot on what actions your application will perform when you start it up. If you have an application that takes five minutes to start up, then every restart will cost a lot. Is there something you can do to reduce the restart time in certain configurations? Can you divide your application into separate deployables to reduce the startup time for each individual application?
It all depends on your needs and requirements.
We used to have long startup times for our local servers, but since we had upgraded disks (SSD-disks) and enough memory the server startup time has been reduced by 80-90%.
I am developing a server application in java (SE) + some open source libraries. This is a game, so I think it will have to be updated sometimes. As long as the app is tracking the state of the clients, using it, and also supports client sessions (in a form of dedicated threads), and singletons, which store references to these player instances, I would like to reload the JVM process (installing a new version of jar file for example), so that some of the classes and instances are not erased by GC, but hooked into the new process started.
Probable Situation:
I have a game version 1.0 running on the server. I need to add some new features in 1.2. But 100 players are fighting each other. I need to install version-1.2, players might feel some lag, but they should be able to continue with their fight even though the version of the jar has changed.
How can that be done?
Take a look at JRebel authors' nice summary on the topic:
http://zeroturnaround.com/blog/reloading_java_classes_401_hotswap_jrebel/#!/
You could look at things like OSGI and class-loading tricks and see if you can achieve what you need, however maybe there is a simpler approach which is a bit safer too.
You could have 2 servers running behind a simple load balancer and when you need to do such maintenance you start routing all new games to Server A only. When all the games on server B finish (and no new games have started because all are going to server A) you stop server B and do whatever maintenance you need to do together with any tests to verify everything is OK before you introduce it back into the 'cluster'.
You then do the same thing and route new games to server B, so that when all games on server A finish you cans switch that off too and do the maintenance.
You will need to develop this simple load balancer which just acts as a connection router but is aware of your game sessions. Maybe you also need to have some information synchronisation between each server instance (if there is any need of communicating lists of players online, chat messages etc., depends what features you have).
First thing to note is that your current game state might be inconsistent with new version. So not all modifications could be installed like this. You can use remote caching system with master/slave configuration. So that all session is stored on remote machine and while one server is stopped, second server can continue working with the same state. First you put down slave, update it and start. Then switch roles and put down second server for update.
I have a big spring application with more than 1000 libraries.
When I do debug frequently not possible only adjust changes without restart, but restart takes a long time (about 5 minutes.) But 1000 libraries remain the same, I have changed only a few rows of code. Is it possible in some way to say to tomcat to apply only classes that were changed?
Thanks.
Use JRebel. In most cases, you can avoid redeploys. It replaces the class without having to restart the container.
Note that I'm not attached to ZeroTurnaround, except as a happy user.