1. Basic information

I graduated from Shuangfei University in the 17th year, mainly engaged in Java development, and have no experience in big factories. I will soon have 3 years of work experience in 2020. If you don’t look for opportunities to further your study in a large factory, it will be more difficult for you to improve your competitiveness and personal development. Therefore, after two years of hard work in the current company, I began to step forward to the big factory. This blog is mainly to share the problems I encountered in the interview process. It was relatively bumpy, and I experienced it for more than three months. I hope you can also look for a job in the process, adhere to it!

2. Interview results

  • Ali - Ant Alipay P6 offer
  • Tencent - PCG 2-3 offer
  • byte 2 the surfaceAfter giving up

3. Interview process

3.1 ali-Tmall Supermarket

One side

1, static proxy, dynamic proxy

A brief description of the differences leads to the underlying implementation of the JDK dynamic Proxy and CGLIb (Proxy and InvocationHandler).

Then introduce the proxy implementation of Spring AOP in different situations

Finally, an example of a dynamic proxy usage scenario in a project (common log printing)

2. Future

A Future is used to represent an asynchronous result. The distinction between executorService. submit and executorService. execute can be drawn

If you have studied the source code of some of the frameworks, you can say what role Future plays in them (timeout control)

3. Thread pool implementation – Destroy threads

The support needs to indicate the relationship between Executors and ThreadPoolExecutor

By setting different input parameters, different thread pools are implemented. The more interesting SynchronousQueue implementation can be studied in depth

Thread pool reclamation: Portal

4, mysql federated index

First introduce what is the federated index, index usage scenarios and ineffectiveness, if you know index down can say what

Leads to the difference between a federated index and a primary key index. Then you can delve into the differences between Innodb and MYISAM

The finishing touch: to write a few SQL to view the index selection rules, you will find that it is not the establishment of the index will go, and is not the index will be pushed down to adopt, this can involve mysql a SQL execution process

5. Redis cluster

The main types of clusters: master-slave, Sentinel, and Redis Cluster. Similar to Twemproxy and Codis such proxy implementation, if you know it can be said.

Detailed question: what kind of scheme is currently adopted by the company (Sentinel), why (less data, master and slave + Sentinel can support business scenarios), and introduce the working principle of Sentinel.

A question was asked: how to notify the client after the master has been selected if the master has died. What is the relationship between the client and the sentinel?

6, mysql database sub-table

First ask: the current capacity of the database is about how much, there is no database table design.

Answer: At present, the data volume of a single table is around 5000W, and the daily growth is less than 10W, so there is no consideration in this regard (the bad is greater than the good).

What are the ways of dividing the library into sub-tables (vertical sub-table, vertical/horizontal sub-table)? We can talk about the implementation of distributed auto-increasing ID, such as the common snowflake algorithm, Meituan-Leaf

7. Project content

Project introduction, mainly to explore your thinking and highlights in your work. After the unified introduction, because each round of interview will basically say onceCopy the code

Second interview

The second interview process is faster, no characteristicsCopy the code
  • Introduce the project and current company profit model
  • The project encountered the greatest difficulty
  • Project design and so on

Total more than 20 minutes, I think it should be no big problem.

The results of

Why so fast to the result, is cold ~

A few days after the interview, I communicated with the second interviewer that I passed and asked me to prepare for the follow-up written test

Maybe it’s a little bit worse than being killed or not having HC

3.2 tencent TEG

One side

HashMap low-level implementation

This section describes the basic structure and compares the differences between 1.7 and 1.8

It is recommended to read the source code of 1.8 resize() in depth, as well as the process of red melanin conversion

Is HashMap thread safe, and if so

Compare the differences and usage scenarios of HashMap,HashTable, and CurrentHashMap

Give a HashMap to use, in the case of thread safety by locking and Collections. On current HashMap SynchronizedMap encapsulation

Introduce the red-black tree

How it works: Red-black tree portal

Application scenario: JDK1.8 HashMap: compares B+ trees and skip lists

What makes Redis so fast

  • memory
  • Single thread
  • The data structure
  • IO multiplex service reuse

Performance bottleneck (memory, network IO), can be pointed out to solve the network IO bottleneck, in Redis 6.0 proposed single main thread, multi-worker thread design. It can be compared with Memecached’s multi-threaded model.

Mysql Index Introduction

  • The difference between clustered and non-clustered indexes (InnoDb vs. MyISAM)
  • Index selection (how the optimizer selects indexes)
  • Index of the failure
  • An index pushdown

Why b plus trees

This paper introduces the difference between B + tree and B tree and compares the advantages of B + tree in disk IO (more indexes can be stored in a single page). It can be mentioned that MONGODB uses B tree index.

Why does MongoDB select B tree and Mysql select B+ tree

Clustered indexes and non-clustered indexes

Reference: Analysis and comparison of clustered and non-clustered indexes

I hit a snag. Clustered indexes and clustered indexes are the same thing

Default primary key index

If the primary key index is not set, innoDB will add a hidden column as the primary key index by default

Why do you need this hidden column? Refer to innoDB’s data store structure

How to design primary key indexes: MySQL Primary key design

Virtual memory and physical memory

Reference: Understanding virtual memory and physical memory

In short:

Physical memory is limited. Virtual memory allocates physical memory by disk mapping to solve the memory shortage problem when multiple processes are running at the same time.Copy the code

False sharing

Pseudo-sharing principle

Can be combined with volatile and ConcurrenthashMap countercell answer

How does TCP ensure reliable transport

  • Packet check
  • reorder
  • Discards duplicate Data
  • Response mechanism
  • Timeout retransmission
  • Flow control

Congestion control

  • Slow start.
  • Congestion avoidance.
  • Fast retransmission.
  • Fast recovery
Computer network this part of the content is relatively more test recitation understanding. You need to put it into your own wordsCopy the code

The project design

Subsequent complementCopy the code

Kafka/ES has not been used

Do you know the latest version of Redis (support multithreading)

Pen test

The content of the pen test is more, there are programming questions, algorithm questions and program running results of multiple choice questions

Second interview

Biggest problem with the project (OOM) – It will be longer

Personal analysis steps, interested can refer to. Mainly according to the theoretical basis for analysis, and then step by step investigation.

Memory leak: Object allocated memory, after the end of the method call did not recycle, directly into the old age of memory overflow: Our memory capacity is insufficient, resulting in insufficient memory allocation mainly from the following two aspects: The first one is memory overflow: the configuration of our machine is a 2-core 4g machine, and the heap memory allocation is 3G, which is allocated in a ratio of 1:2. Here, we can view our heap memory usage through jMAP-heap. Then according to jstat-gc to check our gc times, we can have a rough view of our system GC situation. At that time, by analyzing the gc.log file, we can see that the number of FGC is relatively small, so we can temporarily exclude the possibility of oom caused by our memory overflow. The second is to check for memory leaks. Is used here to - XX: HeapDumpOnOutOfMemoryError command to save oom when the stack information. The memory usage is analyzed by the MAT tool. At that time, the analysis saw that the most memory is the java.util.map object more. The possible cause of memory leak is analyzed through the leak suspects of the MAT tool. What was being located was the method of the interface of one of our student homework reports. Then I took a look at the number of calls to this interface, and found that the number of calls per day was around 200,000, with an average response time of 400 milliseconds. According to the effective information analyzed, the preliminary investigation is that the interface calls a large amount of data, which leads to the generation of more aggregate data (mainly through map aggregation). However, due to the long response time, it is possible that the object is still alive in yGC based on the reachabability analysis (GC root), and then allocated to the old age. When the method call ends, this part of the object will only live in the old age until the FGC is triggered. If this is normal, it should trigger garbage collection during FGC, not oom. If the yGC generates a large number of living objects and olDGC does not have enough memory to store them, it will result in an oom. Optimization process :1. Optimization of THE JVM was mainly done. One was to increase memory, adjust the ratio between the new generation and the old generation (to 1:1), and modify the garbage collectorCopy the code

Why use Redis

The introduction of middleware is to solve the existing problems. For example, the database access pressure is large, the data storage changes frequently, the data access frequency is high and the data timeliness is low.

You can further explain the problems brought by the introduction of Redis and how to solve them. For example, the introduction of Redis to ensure that data is consistent, redis is not available how to ensure that services are available.

Improved throughput after QPS database

Data sensitivity is tested here, and the system is required to be evaluated after each change. Determine if the change improves service performance, by how much, and where are the bottlenecks

Database transaction, innoDB index implementation principle

Transaction isolation level and how it was implemented.

How to achieve this piece of MVCC need to understand

IO multiplexing

Select, poll, and epoll are compared

Have come across in-depth questions about how ePoll event notification is implemented.

Recommended: Linux IO mode and select, poll, and epoll details

Performance bottlenecks, how to optimize

The analysis mainly focuses on the following three points:

  • cpu
  • memory
  • io

RPC call procedure, (why see dubbo source code)

RPC call process this ask a lot of, can refer to dubbo architecture design, and then step by step follow the source code to go through the understanding.

Why to look: Improve your coding and design skills (always look at the source code with the problem, otherwise it’s easy to forget)

Work responsibilities within the group

On three sides

Job content

  • Version of the development
  • Problem processing
  • Distribution of demand
  • Technology review

Refactoring (thinking, implementation)

Suggested reading: Refactoring – Improving the Design of existing Code

What does performance tuning do

JVM tuning, SQL optimization/index reconstruction, and MQ decoupling

The difference between synchronous and asynchronous

Linux IO multiplexing/AIO

Refer to interview 2 above

Linux select notification

B+ trees and red black trees

A HashMap the red-black tree

The mode of interprocess communication

  • The pipe
  • Anonymous pipe
  • signal
  • A semaphore
  • The message queue
  • The Shared memory
  • The socket

System performance bottleneck

The analysis mainly focuses on the following three points:

  • cpu
  • memory
  • io

The results of

The interview with TEG is also N

3.3 tencent PCG

One side

How does RocketMQ guarantee reliable messages

Analyze from the production, MQ, and consumption ends

Message queue technology selection

Compare the common RabbitMQ, RockerMQ and Kafka technology features, combined with the company’s actual scenario choice.

rocketmq half message

This section describes how to call back if half message fails

Rocketmq consumption failed

How to solve the problem of consumption failure, and consumption failure may lead to n+1 problems

Dubbo communication process

RPC call procedure

Dubbo Local cache address

Dubbo underlying source code

Redis Cluster mode

Redis Primary/secondary synchronization

Spring transaction propagation mechanism

Mysql Isolation Level

Redis skip list layer Settings

The above may have more repetitive content, so there is no more detailed introduction, you can go to study again

Second interview

The process of the second interview was a bit like a chat. The interviewer knew people in other departments before me (not TEG above), so they knew the big picture about me. The whole interview process is kind of like coaching, pointing out my weaknesses and giving me some advice. There are also more general questions to ask, which are also some of the things mentioned above.Copy the code

On three sides

Project introduction

The project introduction mainly analyzes the following aspects: 1, business scenario 2, performance data 3, problems and difficulties 4, and performance bottlenecksCopy the code
1. Service scenario

The project of the blogger is a system in the education industry, which mainly describes the business scenario of students answering questions online. You can sort it out according to your own project.

2. Performance data

Performance data should be a more important issue for social recruitment. Basically every round of interviews will be asked how the performance is, which requires us to have a certain understanding of our own system and know how the actual data is. Including: daily visits, service QPS/TPS, the number of users and the number of machines (machine configuration) and other data.

3. Difficulties

Here I will focus on two areas, one is the oom problem location processing mentioned above, and the other is RocketMQ decoupling.

With oom introduced above, here is a brief introduction to RocketMQ in conjunction with the project.

1. Why did RocketMQ be introduced? It was found that the TPS of the core interface was relatively low through the pressure test of the core interface, and it was found that there were relatively more operation steps in the main process after investigation. A write request processes a large amount of content, resulting in slow response of the entire request. The throughput of the interface is improved by splitting the core process and accessibility functions and doing the subsequent work asynchronously. Problem: Slow response, low throughput expectations: fast response, improved TPS Solution: Asynchronous operation/decoupling by introducing RocketMQ 3. How to ensure the reliability of messages from the client, MQ and consumer end to ensure the reliability of messages. Client: Guarantee by transaction message, or failure retry (judged by sendResult) MQ: Guarantee by RocketMQ cluster, mainly responsible for operation and maintenance (may involve MQ message preservation issues) Consumer: 1, 2, water consumption idempotent and table form This problem need to analyze the actual scene in combination with the project, not hard set of 4, the optimized throughput This is the core problem, optimization, you didn't do the performance test, introduced for what good (introduce middleware can reduce system reliability, Therefore, after optimization, a round of stress testing (note that the test scenario should be consistent with the production or the last test scenario) and the consumption rate of messages (to avoid slow consumption resulting in accumulation). 5. Where are the performance bottlenecks after optimization? Mainly from: CPU, memory and IO three aspects of the analysis, specific system specific analysis.Copy the code
4. Difficulties

CPU, memory and IO three aspects of the analysis, specific system specific analysis. There should be no system without bottlenecks.

Hr side

Job content

Team identity

Learning plan

Career planning

Individual performance

offer

After countless hardships, I finally got the offer from Tencent. Although I only wrote the interview content of two departments above, I have met with at least four departments (within two months). Therefore, I have no time to be safe.

3.3 Alaria ants

One side

1, anonymous class, inner class static inner class

2. Differences between HashMap 1.7 and 1.8

3. BlockingQueue

4. Creation forms and usage scenarios of thread pools

5, multithreaded implementation of a counter

6. Wait and notify

7. B+ trees and red-black trees

8. Isolation level of the database

9, how to solve the database magic read

10. Mysql index

Redis distributed locks

12. Redis sentinel cluster

13. Procedure of RPC call

How does ZooKeeper service discovery work

15. Zookeeper heartbeat detection

In general, the interview process is similar to the above, and there is no difficulty. Therefore, we will not do a detailed analysis

Second interview

The second interview is also relatively fast, the main two questions

Project introduction

It’s pretty much the same thing

Scenario questions

User resource permission database design

On three sides

The questions of the three interviewers are mainly related to the business scenario and architecture, which is similar to the three questions of Tencent (actually because they forgot what they asked, which is also related to the project).

All around

The whole process down about 10 minutes or so, just face the headlines, a little sudden.

Project the difficulty

Problem processing

Team roles

Learning methods

Hr side

Hr face a total of 10 minutes or so, the face at that time is also a batch of panic, how so fast. The main question is:

Leaving reason

Career planning

wages

offer

Finally, I successfully got the offer from Ali and fulfilled my ideal! Later to walk with nine spirit river’s lake ~~

4. Summary and suggestions

In the interview process, the author is not smooth sailing, but also through the thorns, 2020 is not a stable time, every day in a variety of changes. Only adhere to, grasp, do not give up to achieve their goals.

Come on, boy!

Finally, I will post a new student’s public account (Java tutorial), welcome your attention, mainly share the interview content (refer to the previous blogger’s article), Ali’s open source technology and ali life related. Want to exchange interview experience, can add my personal wechat (JayCE-K) into the group learning ~