Java Interview Four – Linux Common Directive

1.Linux common instruction

a) TOP – Observe the occupation of the CPU from the macro viewing system and memory usage

i. Processes statistics (total processes, running processes, sleep processes, etc.)

II.cpu statistics (user CPU occupied, kernel CPU occupation, etc.)

III. Memory Information (Total physical memory, the physical memory, free physical memory, total amount of exchange zones, exchange zones used)

IV. Process Details (ID, CPU usage, memory, shared memory size, use CPU time)

v. top -h -p Outputs the operation of all threads in a particular process

b) PidStat – The case used to monitor all or specified processes, such as CPU, memory, device IO, task switching, thread, etc.

i. Command form is “pidstat [option] interval [count]”

II.-UCPU usage statistics

III.-R memory usage statistics

IV.-DIO statistics

V.-P statistics for specific processes

c) DSTAT – is a multi-functional product that can replace VMSTAT, IOSTAT, NetStat, and IFSTAT.

By default, five areas: CPU usage, disk statistics, network statistics, memory page statistics, system information

I.-L: Display load statistics

II.-M: Display memory usage (including Used, Buffer, Cache, Free Value)

III.-R: Display I / O statistics

IV.-S: Show exchange partition usage

V.-T: Display the current time in the first line

Vi.-fs: Display file system statistics (including total number of files and inodes values)

VII.-Nocolor: Does not display color (sometimes useful)

Viii.-Socket: Display Network Statistics

d) NetStat – Monitor TCP / IP Network Status

e) ifstat – Statistics Network Interface Traffic Status

f) vmstat – display virtual memory status

g) iostat – monitoring system input and output devices and CPU usage

h) JPS -L – Show all PIDs and class names of all Java processes

i) JStack – thread stack information of the Java application

I.jstack – View the stack status of the current process,

j) Printf% x – Get 16-enumerated value of PID

K) JSTAT – Tools used to observe the run of the Java program,

I.-GC: Display Pile Information related to GC

II.-gccapacity: Displays the capacity and usage of each generation

l) Jinfo – View the JVM parameters of the running Java program and support the runtime to modify individual parameters

Jinfo [option]

I. -flags Parameter Value of Print JVM

Ii. -flag = Settings Specify JVM parameter values

III. -flag [+ | -] Setting the boolean value for the specified JVM parameter

m) JMAP – Statistics of the pile of Java applications and objects

Jmap -histo 17338> jmap.log

JMap -dump: Format = B, file = Heap.hprof 17338 Generates Snapshot Information

n) jhat – You can analyze the pile of java programs

Jhat Heap.hprof Visit 7000 Port through the browser to view the pile snapshot information

2.CPU use efficiency monitoring

a) Find the PID of the Java program using JPS -L

b) Use the PIDSTAT -P -U -T 1 3 to output the CPU usage of the PID process and find threads with high CPU usage.

c) Use top -p -h can also view threads with high CPU usage

d) jstack > jstack.log input thread stack log

e) PrintF% x converts PID to 16-credit format

f) Analyze the relevant logs of corresponding NID = 16 credit line numbers in jstack.log

3.IO usage monitoring

a) Find the PID of the Java program using JPS -L

b) Use PIDSTAT -P -D -T 1 3 to output the IO usage of the PID process and find threads with high IO usage.

c) Subsequent analysis methods and CPU analysis methods are the same 4. Memory usage monitoring

a) pidstat -p 17338 -r 1 3

5.GC efficiency monitoring

JSTAT -GC 12538 5000 will display the GC condition of Java processed by 12538 every 5 seconds.

6. High concurrent Linux server foundation setting

a) Modify the number of files that can be opened by the user process

Modify /etc/security/limits.conf file

Soft Nofile 65535 Hard Nofile 65535

b) Enable TIMEWAIT Quick Recycling

Net.IPv4.tcp_tw_recycle = 1

c) TimeWait quantity, default is 180000

NET.IPV4.TCP_MAX_TW_BUCKETS = 6000

d) Turn on reuse. Allow TIME-WAIT Sockets to be reused for new TCP connections

Net.IPv4.tcp_tw_reuse = 1

e) Port range allowed to open

Net.IPv4.ip_local_port_range = 1024 65000

f) Turn on SYN Cookies, enable cookies to process when SYN waits for the queue overflow.

Net.IPv4.tcp_syncookies = 1

g) The backlog of the listen function in web application will give our core parameters net.core.somaxconn to 128, and NGX_Listen_BackLog defined by Nginx is 511, so it is necessary to adjust this value.

Net.core.somaxConn = 262144

h) The synthesis is required to turn off the timeout time, determine the time it remains in the FIN-WAIT-2 state, the default value is 60 seconds

Net.IPv4.tcp_fin_timeout = 5

i) means that the TCP sends the frequency of the LeepAlive message when Keepalive is used. The default is 2 hours, and it is changed to 10 minutes.

Net.IPv4.tcp_keepalive_time = 600

j) Indicates the length of the SYN queue, default is 1024, and the queue length is 10240, which can accommodate more network connections.

Net.IPv4.tcp_max_syn_backlog = 10240

k) indicates that the number of SYN packets is sent before the internal nuclear discarding connection, and the default is 5.

Net.IPv4.tcp_syn_retries = 1

l) The value of the parameter determines the number of SYN + ACK packets before the kernel is abandoned, and the default is 5.

Net.ipv4.tcp_synack_retries = 1

Related Posts