prepare for 秋招

JVM memory layout

(1) threads share the
Java heap
Eden District
Survivor area
method area
(2) threads do not share the
virtual machine stacks
native method stacks
program counter

Database Objects

Triggers, tables, views, stored procedures, indexes, default values, chart, users, rules, and so on it.

The type of database index

(1) full-text index
(2) hash index
(3) BTree index
(4) RTree Index

(1) General Index: only speed up queries
(2) unique index: speed up queries + column value unique (there may be null)
(. 3) primary key index: speed up queries + column value uniquely (not have null) + table only one
( 4) composite index: multi-column values into an index, a combination of dedicated to searching, combined efficiency is higher than the index
(5) full-text index: the content of the text into the word, search

How to address the high concurrency

(1) html static
(2) image server separation. The establishment of a separate image server
(3) using the database cluster. Library Hash Table
(4) caching
(5) mirror
(6) Load Balancing

sql optimization direction

(1) fewer number of connections table. The more links, the poorer the performance
(2) If this is unavoidable, you can use temporary tables to store temporary results
(3) less subquery
(4) nested views should not be too deep
(5) Try not to let the index failed
NULL column is not It allows the use of the index.
String concatenation indexes will also fail
like a wildcard index will fail
order by clause medicine to make use of the index field
not also cause operational failure index.
(6) exits in place of

awk command

https://blog.csdn.net/jin970505/article/details/79056457

tcp state machine

Here Insert Picture Description
Here Insert Picture Description

[Extensions] linux log processing and other monitoring

https://www.cnblogs.com/dion-90/articles/8568129.html

uptime command

uptime
  08:21:34 up 36 min,  2 users,  load average: 0.00, 0.00, 0.00
 
#当前服务器时间:    08:21:34
#当前服务器运行时长  36 min
#当前用户数          2 users
#当前的负载均衡      load average  0.00, 0.00, 0.00,分别取1min,5min,15min的均值

sar command

Performance Monitoring

iostat

Device: device name displayed in the form sdX
tps: IO per second delivered by the read process, the number of write requests
KB_read / s: the second amount of read data driver, in K.
KB_wrtn / s: the amount of data from the second write driver, in K.
KB_read: total amount of data read, in K.
KB_wrtn: the amount of data written, in K.

Reverse list

 public static Node reverseList(Node head)
    {
        if(head == null || head.next == null)
            return head;

        Node preNode = null;
        Node currentNode = head;
        Node nextNode = null;

        while(currentNode!= null)
        {
            nextNode = currentNode.next;
            currentNode.next = preNode;
            preNode = currentNode;
            currentNode = nextNode;
        }

        return preNode;
    }

I have a wrong answer:
Here Insert Picture Description

select poll epoll

https://www.cnblogs.com/aspirant/p/9166944.html

1, support the maximum number of connections a process that can be opened

select

Maximum number of connections that can be opened with a single process FD_SETSIZE macro definition, which size is the size of 32 integer (32-bit machine, the size is 3232, the same way as 64-bit machine FD_SETSIZE 3264), we can of course be modify and then recompile the kernel, but performance may be affected, which requires further testing.

poll

And select the poll no essential difference, but it does not limit the maximum number of connections, because it is based on a linked list to store

epoll

Although the number of connections has an upper limit, however great, can open a connection of about 100,000 on the machine 1G memory, 2G memory machines can be connected to open around 200,000

2, FD brings the dramatic increase in the efficiency of IO

select

Because of the connection will be linear traversing each call, so as FD increases will result in slower traverse the "linear performance degradation issues."

poll

Ditto

epoll

Because epoll kernel implementation is achieved according to the callback function on each fd, only active socket will take the initiative to call callback, less so in the case of active socket, the use of performance issues epoll no linear decrease in both the front but when all the socket are active, there may be performance issues.

3, messaging mode

select

The kernel needs to deliver the message to the user space, kernel copy operation requires

poll

Ditto

epoll

epoll achieved through a shared kernel and user space memory.

hdfs advantages and disadvantages

advantage

1. high fault tolerance

Copy mechanism

2. Suitable for batch processing

"Mobile Computing"

3. suitable for large data processing

4. streaming access

Write Once Read Many.

The machine can be built inexpensively above

Mainly high reliability

Shortcoming

1. The delay of scenes not suitable for high throughput

2. impractical to store vast amounts of small files

3. does not support concurrent write, modify the file of random

hdfs of RPC

linux memory management

From the process address space: Let's talk about the stack segment, and then talk about four tables and five pages tlb memory access time, revisit the page fault interrupt. Page fault when various anonymous file mapping and file mapping, file mapping needs to allocate a page cache and execute dma, but anonymous file mapping by the memory management code management, specifically, by a buddy allocator. May face physical memory runs out, speak lru. Then replace the lost data which, if it is anonymous memory, disk will be thrown into the exchange zone.

(1) summarize the text: https://software.intel.com/en-us/articles/how-memory-is-accessed
()

Mapping virtual addresses and physical addresses

Linux paging mechanism

[Page offset address within the page]] [
page table
multi-level page table
TLB (Translation Lookaside Table)

tlb miss is costly, solutions are as follows:
(1) size of the modified page
(2) Page Huge
(. 3) Carefully Planning The How in your Data Pages FITS

Page fault

https://blog.csdn.net/a7980718/article/details/80895302

Cache replacement

active inactive
two flag: PG_referenced and PG_active

cpp procedural issues under Linux diagnostic and tuning

A, cpu problem

1. uptimecommand

up how long. There is no machine can be restarted quickly found
Log how many user
to view the load

2. vmstat

Virtual memory monitor
Here Insert Picture Description

3. top command

4. strace

You can analyze specific thread time-consuming system calls

5. Analysis cpu bottleneck --perf

6. accurate performance analysis to function - Flame FIG.

7. Analyze resource consumption of each thread in the thread function consumption: valgrind

Implementation of each thread stack 8. Analysis program: pstack & pt-pmp

Memory Problems

(1) the development of requirements: to avoid manual memory management. Try to use shared_ptr, unique_ptr other smart pointers.
(2) valgrind tool
(3) optimized for multi-threaded general purpose memory bank. jemalloc and TCMalloc
(4) as Free -HW observe the memory usage
(5) take the initiative to clean up the page cache, active sync refresh dirty pages
(6) closed swap

IO problems

Observing disk IO case

(1) dd command: a simple test io performance disk
(2) fio: random access performance test
(3) iostat

IO observation process and handle

(1) iotop: observation of each process IO consumption
(2) Check the process handle the case through the proc filesystem: ls /proc/87091/fd -l
(3) lsof: View the process handle the situation

Internet problem

(1) netstat: View network connection information
(2) lsof: View to open the process of port lsof -i :36000
(3) sar command: View the card and package volume flow
sar -n DEV -n EDEV 1
(4) tcpdump: problem diagnosis data transmission
(5) wireshark tool

other

gdb
log

Published 306 original articles · won praise 46 · views 290 000 +

Guess you like

Origin blog.csdn.net/kaikai_sk/article/details/100174245