When do we create multiple instances of the same application?

The Java Virtual Machine Runtime Instance has a clear mission in life: to run a single Java application. When the Java application starts, a run-time instance. When the application terminates, the instance dies. If you simultaneously run three Java applications on the same computer using the same specific implementation, you will get three instances of the Java virtual machine. Each Java application runs inside its own Java virtual machine.

I was viewing this article on an instance at runtime, I just did not understand about the lines above.

public class Test1 { public static void main(String args[]) { if (args.length > 0) { try { for (int i = 0; i < args.length; i++) { System.out.println("Args" + args[i]); } } catch (Exception e) { e.printStackTrace(); } } } } 

When I run the above class, a run-time instance is born. As soon as it completes this operation, the run-time instance goes out.

  • Take stackoverflow.com somewhere on the Internet, is one instance of the application sufficient to serve people, or depending on the load and traffic, we create a different instance of the same application from different servers / computers. How and when do you decide we need to create different instances of the same application?

  • What does the same concrete implementation mean here? How about various specific implementations.

I apologize if my questions are rather vague anyway, I am learning java but working entirely on HTML/CSS and JS .

http://www.artima.com/insidejvm/ed2/jvm.html

+4
source share
3 answers

pretty vague: right and so answer

2 a concrete implementation is a class that has an implementation for its entire method (as opposed to an abstract class / interface)

1 You can stretch your application horizontally, if necessary, in a cloud deployment

+1
source

Java machines for personal computers are programs such as Word or Internet Explorer or Adobe Reader.

The way they are designed is that if you run three Java programs at the same time, each program has its own JVM, which will process it, and not open multiple tabs in one browser window).

A word instance refers to the operating system, treating them as running programs, not just files on your hard drive with a lot of bytes called EXEs.

A specific implementation relates to a given Java installation, for example. C:\Programs\Java\Java-7.1.2.3\bin\java.exe . If you run this program three times, you will have three running instances, not just one.

+1
source

1 How and when did you decide to create different instances of the same application?
If, for example, you want the application to be located next to the user, then you can deploy one of them on a server in Asia, one in the EMEA region and in the USA. When your user tries to access it, you direct them to the server closest to you, and they can get the most responsive user experience.

Now - this is impossible in all cases, as if you were sharing data (for example, if you were a bank), then you would need to manage the data in such a way that they are consistent between the three instances of your application. This, though, may be a topic for another question.

2: The same specific implementation. This is usually used when you access an abstract class and select a specific implementation of the class. For example, if you have an abstract class "Car" and there is a specific implementation that implements if "Ferrari".

In this case, he uses the same terminology, but not so often. When a text refers to a specific embodiment in this context, it says that it is the same program. those. you copy and paste ".exe" and start it again. In Java terms, you must copy the same ".jar" files and execute them.

However, in this case you can do it on different machines or, as indicated, you can run them on the same computer, and if you look in memory, you will see three separate Java processes.

+1
source

Source: https://habr.com/ru/post/1486711/


All Articles