[JAVA] I took a look at the resources of Azure Container Instance

In the article of Dive to Java (@YaSuenag, @sugarlife) of Web + DB Press Vol.106, see the information that the resource control of cgroup is not visible from the JVM in Java 8 (resource control is possible in Java 10). , I wanted to try it on Azure (ACI), so I tried it.

Creating a Container

I will do various things, so I will create an instance that connects with SSH. While looking for Docker Hub, I borrowed the image of here. Please refer to the link for the root password etc. when using it.

Deploy the container on Azure Cloud Shell.

$ az group create --name con01 --location eastus
$ az container create --resource-group con01 --name con01 --image rastasheep/ubuntu-sshd --dns-name-label con01 --ports 22

Connect with SSH and install Java 8.

# apt-get update
# apt-get install openjdk-8-jre
# apt-get install openjdk-8-jdk

# java -version
openjdk version "1.8.0_181"
OpenJDK Runtime Environment (build 1.8.0_181-8u181-b13-0ubuntu0.18.04.1-b13)
OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode)
# javac -version
javac 1.8.0_181

If you install it with default-j **, Java 10 is included.

# apt-get install default-jre
# apt-get install default-jdk

# java -version
openjdk version "10.0.2" 2018-07-17
OpenJDK Runtime Environment (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.2)
OpenJDK 64-Bit Server VM (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.2, mixed mode)
# javac -version
javac 10.0.2

Compile the sample code that was included.

public class Main {
  public static void main(String[] args){
    Runtime rt = Runtime.getRuntime();
    System.err.format("VERSION : %s%nCPU : %d processors%nHeap : %s%n",
                      System.getProperty("java.version"),
                      rt.availableProcessors(),
                      humanRedable(rt.maxMemory()));
  }

  private static String humanRedable(long bytes){
    int unit = 1024;
    int exp = (int) (Math.log(bytes) / Math.log(unit));
    return String.format("%4.1f %sB",
                         bytes/Math.pow(unit,exp),
                         " KMGTPEZY".charAt(exp));
  }
}

When you run ...

# javac -cp . Main.java
# java -cp . Main
VERSION : 1.8.0_181
CPU : 1 processors
Heap : 464.0 MB

that? 1 processors? Something unexpected. I was expecting it to be a little bigger. Oh yeah. Is the container host itself 1 Core?

Let's take a look at / proc / cpuinfo as well.

# cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 63
model name      : Intel(R) Xeon(R) CPU E5-2673 v3 @ 2.40GHz
stepping        : 2
microcode       : 0xffffffff
cpu MHz         : 2397.214
cache size      : 30720 KB
physical id     : 0
siblings        : 1
core id         : 0
cpu cores       : 1
apicid          : 0
initial apicid  : 0
fpu             : yes
fpu_exception   : yes
cpuid level     : 15
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm invpcid_single kaiser fsgsbase bmi1 avx2 smep bmi2 erms invpcid xsaveopt
bugs            : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf
bogomips        : 4794.42
clflush size    : 64
cache_alignment : 64
address sizes   : 44 bits physical, 48 bits virtual
power management:

Hmmm, it's one core. Looking at here, it seems that the restrictions can be set well on the container host side, but in that case, look at uptime. And, is it the count from the container start timing?

In the environment, about 15 minutes after startup

# cat /proc/uptime
5132.17 4473.34

It was like this, so it didn't seem to be counted from the start.

So I wonder if the original container host is 1 Core.

If you think wrong, please point out: bow_tone1:

Well, the result was a little different from what I had imagined, but I'm glad I learned it.

Recommended Posts

I took a look at the resources of Azure Container Instance
I took a peek at the contents of Java's HashMap
Let's take a look at the screen of Quant Analyzer!
I tried to take a look at the flow of Android development environment construction with Android Studio
A quick look at the Monty Hall problem
Let's take a look at the functions of Keycloak's management console (administrator edition)
I wrote a sequence diagram of the j.u.c.Flow sample
I took a second look at Tribuo published by Oracle. Tribuo --A Java prediction library (v4.0)
I learned about the existence of a gemspec file
Let's take a look at the functions of Keycloak's management console (user edition), user account service
I took a quick look at how WebView's Javascript Interface is called when using OkHttp.
Let's take a look at the Hotspot JVM startup procedure
Why put a line break at the end of the file
I investigated the enclosing instance.
I created a Docker image of a container for learning OpenAI Gym
A solution to the problem of blank spaces at the beginning of textarea
I made a Ruby container image and moved the Lambda function
Get a proxy instance of the component itself in Spring Boot
[Java] Let's take a look at Switch Expressions (Preview) of JDK 13.
I tried using the cache function of Application Container Cloud Service
I made a gem to post the text of org-mode to qiita
I made a tool to output the difference of CSV file
A quick look back at Java over the last five years
I read the source of Integer
A memorandum of the FizzBuzz problem
I read the source of Long
I read the source of Short
I read the source of Byte
I read the source of String
A nice workaround when "having an instance of either of the two classes"
I tried running the route search engine (OSRM) easily with a container
How to change the value of a variable at a breakpoint in intelliJ