To introduce myself

Most interviewers will ask you to introduce yourself. I think there are two main functions of introducing yourself

The first one is to give the interviewer time to look at your resume. What would be a good question for him to ask you

The second is that the interviewer wants to hear if there are any problems with your presentation

Generally speaking, it is best to recommend self-introduction in advance, first several times, so that there is a head about. Time position three minutes or so on the good, too long to carry back, too short the interviewer resume did not read.

Attached I often used to introduce myself for your reference

Hello, my name is Zhang SAN. I have led X companies and have had X years of Java development experience. The first company is XXXXX, mainly engaged in XXXX, and I am mainly responsible for XXXX. The second company is to do what what, I am mainly responsible for what, in a recent project, achieved a certain result…..

Of course, the above content is certainly not three minutes, so please expand it according to your own situation

Eight-part essay writing

As for these problems, there are usually traces to follow, and there are also a lot of online experiences to share. I mainly want to share with you some thoughts on the topics that I have a deep impression on eight-part essay.

Tell me about a ThreadLocal

When I heard this opening scene, I felt pretty stable. I’ve written about ThreadLocal before. I just shuttled, and the interviewer didn’t say anything for a long time.

We’re going to start with the underlying data structure of ThreadLocal, and we’re going to start with the InheritableThreadLocal because the child thread can’t get the value of the parent thread.

And because InheritableThreadLocal does not solve the problem of obtaining the parent thread value when using the thread pool, because the thread in the thread pool is reusable, the value may be modified in the child thread, so that the child thread gets the incorrect value. Alibab TransmittableThreadLocal if there is any issues with alibab TransmittableThreadLocal if there is any issues with Alibab TransmittableThreadLocal if there is any issues with Alibab TransmittableThreadLocal if there is any issues with Alibab TransmittableThreadLocal

ThreadLocal can leak memory, and how to check for memory leaks.

After that, the interviewer usually stops asking questions because I’ve already said all I need to say.

Previous articles on ThreadLocal can be found here: juejin.cn/post/695054…

If you could design a thread pool, what would you do?

This is essentially a thread pool, just to explain the core principles of thread pools.

Thread pools are created using ThreadPoolExecutor. Thread pools are created using ThreadPoolExecutor. Thread pools are created using ThreadPoolExecutor.

The blocking queue must use a bounded queue, how many reject policies are there, what is the default behavior, and the special policy CallerRunsPolicy(if the thread pool is not closed, it is executed by the thread that calls the thread pool)

The Tomcat thread pool is first expanded to the maximum number of threads, so that redundant tasks that cannot be processed are put into the queue.

Finally, thread pool parameters allow dynamic adjustment if you design them.

Related articles

Juejin. Cn/post / 686066…

Juejin. Cn/post / 684490…

Talk about Redis distributed locks

SetNX is a command that can be used to release a lock in a different thread. This command can be used to release a lock in a different thread. It can be used to release a lock in a different thread

Zookeeper implements distributed locks, such as ordered nodes, temporary nodes, event listeners, etc., generally using open source client curator implementation.

And then finally compare the two, for example

  1. If Redis fails to acquire the lock, it will consistently attempt to acquire it, consuming performance
  2. Redis data is not very consistent, it can be problematic in extreme cases, and RedLock cannot guarantee it completely
  3. Zk design positioning is strong consistency, lock model robust, suitable for distributed lock
  4. Zk can’t get locks, just add listeners instead of rotating

Zk also has disadvantages, that is, when many clients frequently apply for locks and release locks, the ZK cluster will be under great pressure.

How to handle excessive time_wait?

From four waves to how to produce time_wait to more? How to solve. This is a sequential chain.

A TCP connection is in TIME_WAIT state, which is specified by the TCP protocol. The active close state is in when the four waves are waved, and the port is not released during this period (MSL=2 minutes). If the number of concurrent waves is large, the port will be insufficient, which affects the new TCP connection.

We can set the corresponding system parameters (reuse_buckts) by setting the corresponding system parameters. I just need to know that there are parameters to control), and reuse these connections.

How do I do Tomcat tuning?

You can answer from four aspects: I/O model, JVM memory, thread pool and network optimization.

NIO2 can be considered if Tomcat is running on Windows, since true asynchronous IO is implemented from the operating system level, and NIO is still recommended for Linux servers, since the JVM implements asynchronous IO via epoll at the application level.

JVM memory refers to the JVM memory model (not JMM), and is explained for young generation, old generation, Metaspace, etc., as well as some configuration parameters, garbage collector, etc.

Network optimization can start with TCP’s half-connection queue and accept queue. Semi-connection queue: Holds connections in SYN_RECV state. The queue length is set by net.ipv4.tcp_max_syn_backlog. Accept queue: Saves connections in the ESTABLISHED state. Queue length is min(net.core.somaxconn, backlog). Backlog is the argument we specified when we created the ServerSocket, which is ultimately passed to the LISTEN method. Backlog in Tomcat corresponds to the acceptCount value.

AcceptCount defaults to 100 and net.core.somaxconn defaults to 128. As you can imagine, in a high concurrency situation, when Tomcat has no time to process new connections, they are piled up in the Accept queue. The acceptCount parameter controls the length of the Accept queue. When the length exceeds this, the kernel sends an RST to the client. This will trigger the “Connection reset” exception mentioned above

Therefore, we need to consider the values of these two parameters when configuring Tomcat

How does Kafka Exactly Once guarantee that?

Kafka guarantees at least once that data is persisted only once on the Server when Producer sends the same message

  1. Only the Producer can be guaranteed to keep losing or reproducing data in a single session
  2. Idempotence cannot span multiple topic-partitions, but only within a single Partition. When multiple topic-partitions are involved, the states in between are not synchronized.

Set enable.idempotence to true

The realization principle of idempotent of Producer Kafka Producer has the following two important mechanisms:

  1. PID (Producer ID), which identifies each Producer client.
  2. Sequence numbers: Each message sent by the client carries the corresponding sequence number. The Server checks whether the data is repeated based on the sequence number.

Meanwhile, when setting idempotency, producer requires MAX_IN_FLIGHT_REQUESTS_PER_CONNECTION to be less than or equal to 5, because the server caches only the last 5 Batches.

If you want to guarantee multiple partitions, you need transactions

What should we pay attention to in mysql index optimization?

Let’s start with the mysql B+ tree structure, and then talk about some important points. Such as

  1. Do not have more than three table joins
  2. Small table drives large table when join
  3. Try to go to the primary key index, avoid back to the table
  4. Build indexes for highly differentiated columns
  5. Left-most matching rule, like ‘xx%’
  6. Query required columns, not all columns, without calculations, functions, etc
  7. explain

.

What’s the difference between Synchronized and ReentrantLock

First talk about the principles, then compare the similarities and differences.

Synchronized Synchronized -> lightweight -> heavyweight -> CLH -> Pthread

ReentrantLock –> Usage –> Principle (AQS) –> unsafe. park –> pthread

Other concurrent utility classes under AQS can also be extended

If you’re interested, check out my series on concurrent programming.

How does SpringBean solve circular dependencies?

I know you are going to say three level cache, said before the best look at the source code to form their own ideas, light is not back.

And then the interviewer will ask you, is it ok to just have two levels? If you say no, the interview is over.

If you say yes, think about it and ask what needs level 3? (agent)

project

  1. QPS, RPS?

  2. Have you ever had the most difficult online problem?

  3. What if traffic on your project jumps 10 times?

  4. What was the highlight of your project?

The fewer words, the bigger the problem.

To tell the truth, the proportion of these open questions is much larger than the Eight-part essay, because there are a lot of questions on the Eight-part Essay website, but these projects related, each person is unique. So the usual time to think more about this kind of problem, more summary.

These are the most representative questions that are often asked, and I hope they will be helpful.

What if I can’t answer?

What do you say to lying flat?

It’s normal to not be able to answer some questions, they may be interpreted differently, and even if they are answered, they may not be what the interviewer is looking for.

If you don’t know the meaning, ask. If you really can’t, you can’t answer it, or tell the interviewer how you think about it. Treat the interview as a technical exchange, and your attitude will be better.

Before the interview, it’s best to have some common questions to know

Be confident!

If you are confident, 60% of your interviews will be successful.

And finally, there you go. Does my confidence deserve a thumbs up? (Manual dog head)