BAT interview questions, answer the correct annual salary of one million, 10 people 9 hanging!

Originally, after the opening of the new year was the peak season for interviews and recruitment, gold three silver four has always been the best time for programmers to change jobs, but due to the outbreak of the epidemic this year, gold three silver four became "gold five silver six"!

Many people have added my WeChat friends these days and asked me for some interview questions. I have prepared about 500 interview questions here, covering a very wide range, and I will share it with you for free today!

Let me give you a brief list first!

The reason for Kafka's high performance?

Reference answer:

A, Broker NIO asynchronous message processing, realizes the separation of IO thread and business thread;
B, disk sequential write;
C, zero copy (skip the copy of the user buffer, establish a direct mapping between disk space and memory, data is no longer copied To the user-mode buffer);
D, partition/segment (each file operation is an operation on a small file, which is very light and also increases the parallel processing capability);
F, batch sending (you can specify the cached messages to reach Send out when a certain amount, or send out after buffering for a fixed period of time, greatly reducing the number of I/O on the server side)
E, data compression

The idempotent approach?

Reference answer:

1. Query and delete operations are naturally idempotent
2. Unique index to prevent new dirty data
3. Token mechanism to prevent repeated page submission
4. Pessimistic lock for update
5. Optimistic lock (implemented by version number/time stamp, passing conditions Restrict where avai_amount-#subAmount# >= 0)
6. Distributed lock
7, state machine idempotent (if the state machine is already in the next state, at this time there is a change in the previous state, which cannot theoretically be changed , In this case, the idempotency of the finite state machine is guaranteed.)
8. select + insert (backend system with low concurrency, or some task JOB, in order to support idempotence, support repeated execution)

How to deal with RabbitMQ message accumulation?

Reference answer:

Increase consumer processing power (such as optimizing code), or reduce release frequency

Simply upgrading the hardware is not a solution, it can only play a temporary role

Consider using the maximum queue length limit, RabbitMQ 3.1 supports

Set the age of the message and discard it when it expires

By default, rabbitmq consumers are single-threaded serial consumption. Two key attributes of concurrent consumption are set, concurrentConsumers and prefetchCount. The concurrentConsumers setting is the number of concurrent consumers set at the time of initialization for each listener, and prefetchCount is each time. The number of messages to be consumed from the broker at one time

Create a new queue, and consumers subscribe to the new and old queues at the same time

The producer side caches the data and sends it to mq after the mq is consumed

Break the sending loop condition and set the appropriate qos value. When the qos value is used up and the new ack is not received by mq, you can jump out of the sending loop to receive new messages;

Consumers take the initiative to block the receiving process. Consumers take the initiative to block when receiving messages too fast, and use block and unblock methods to adjust the receiving rate. When the receiving thread is blocked, the sending loop is jumped out.

Create a new topic, the partition is 10 times the original;

Then write a temporary consumer program that distributes data. This program is deployed to consume the backlog of data. After consumption, it does not do time-consuming processing, and directly polls and writes the temporarily established 10 times the number of queues evenly;

Then temporarily requisition 10 times the machines to deploy consumers, and each batch of consumers consumes a temporary queue data;

After the backlog of data is consumed quickly, the original deployment architecture has to be restored, and the original consumer machine is used to consume messages;


Load balancing algorithm?

Reference answer:

There are 6 common load balancing algorithms: round-robin, random, source address hashing, weighted round-robin, weighted random, minimum number of connections.

nginx 5 load balancing algorithms: polling, weight, ip_hash, fair (response time), url_hash

Dubbo load balancing algorithm: random, polling, minimum number of active calls, consistent Hash.

What are the specific scenarios of JVM YGC and FGC?

Reference answer:

The transaction function being processed will be automatically rolled back next time.

The queue realizes persistent storage and will be automatically loaded next time it is started.

Add flag bit, unprocessed 0, processing 1, and processed 2. Every time it starts, set all the statuses as 1 and set them as 0.

The critical application is to equip the computer with a UPS.

YGC: Perform gc on the young generation heap. The frequency is relatively high, because most objects have a short lifespan and are collected in the young generation. The performance cost is small.
FGC: gc of the whole heap range. When the default heap space usage reaches 80% (adjustable), fgc will be triggered. Taking our production environment as an example, fgc is generally triggered rarely, sometimes once every 10 days or a week.

Scenario where YGC occurs: edn space is insufficient.
Scenarios where FGC occurs: insufficient old space, insufficient perm space, calling method System.gc(), pessimistic strategy when ygc, dumping live memory information (jmap -dump:live).

A thread pool is processing a service, what if there is a sudden power failure?

Reference answer:

The queue realizes persistent storage and will be automatically loaded next time it is started.
But the actual situation depends on the situation, the general idea is this.
Add flag bit, unprocessed 0, processing 1, and processed 2. Every time it starts, set all the statuses as 1 and set them as 0. Or timer processing.
The critical application is to equip the computer with a UPS.

I won’t list more interview questions, there are too many. It is impossible to list them one by one, I have prepared several PDF documents. Screenshot below:

JVM interview questions.

BAT interview questions, answer the correct annual salary of one million, 10 people 9 hanging!

Java data structure interview questions.

BAT interview questions, answer the correct annual salary of one million, 10 people 9 hanging!

SpringBoot and SpringCloud interview questions.

BAT interview questions, answer the correct annual salary of one million, 10 people 9 hanging!

I won’t take screenshots for more, add my WeChat ID: codedq (if you have added xmtxtt and xttblog, don’t add them again), I will send them in the evening.

Guess you like

Origin blog.51cto.com/15127565/2664738