Send you the following BAT big factory interview questions, at the end of the paper will be available

1. Basic information

The blogger graduated from the 17th session of Shuangfeiyi, mainly engaged in Java development, and has no experience in big factory. 2021 himself will soon have 4 years of working experience. If we don’t look for an opportunity to enter Dachang for further study, the competitiveness and personal improvement will be more difficult. Therefore, after two years’ experience in my current company, I began to move to Dachang. This blog is mainly to share the problems I encountered in the interview process, which was relatively bumpy and lasted for more than three months. I hope you can stick to it in the process of looking for a job!

2. Interview results

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

3. The interview process

3.1 Ali-Tmall supermarket

One side

1, static proxy, dynamic proxy

A brief description of the differences can then lead to the JDK dynamic proxies and the underlying implementation principles of CGLIB (Proxy and InvocationHandler).

Then introduce the proxy implementation that Spring AOP uses in different situations

Finally, an example of a use scenario for dynamic proxies in a project (common log printing)

2. Future (Key Points)

Future is used to represent an asynchronous result. Submit the difference between executorService.execute and executorService.execute

If you’ve looked at the source code for some of the frameworks, talk about the role that Future plays in them (timeout control).

3. Thread pool implementation – destroy threads

The support needs to indicate the relationship between Executors and ThreadPoolExecutors

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

Thread pool recycling: Portal

4. MySQL federated index

First of all, what is a federated index, index usage scenarios and failure situations, if you know the index push can say

What is the difference between a federated index and a primary key index? Then you can look in depth at the differences between InnoDB and MyISAM

The punchline: to write a few SQL to view the index of the selection rules, you will find that is not set up the index will go, is not the index will be pushed down to use, this can be involved in MySQL a SQL execution process

5. Redis Cluster

The main types of clusters: Master Slave, Sentinel and Redis Cluster server clusters. Such as TWEMProxy and CODIS proxy implementation, if you know it can be said.

Detailed questions: what kind of solution (sentinel) is adopted by the company at present, why (small amount of data, master-slave + sentinel can support business scenarios), and introduce the working principle of sentinel.

A question was asked: how to notify the client when the master dies and the master is selected. What is the relationship between the client and the sentinel?

6, MySQL library and table

First ask: the current capacity of the database is about how much, have to do the design of sub-library sub-table.

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

Then leads to: what are the ways of the library and table (vertical library, vertical/horizontal table), to explain the difference. You can talk about the implementation of distributed self-increasing ID, such as the common snowflake algorithm, Meituan-Leaf

7. Project content

Project introduction, mainly to dig out your thinking and highlights in the work. Behind the unified introduction, because each round of interview will basically say once

Second interview

The process of the second interview is fast. What are the features
  • Introduce the project and current company’s profit model
  • The project encountered the greatest difficulty
  • The project scheme design and so on

Twenty minutes in all, it doesn’t feel like a big deal.

The results of

Why so fast to the result, it is cool ~

A few days after the interview, I communicated with the interviewer for the second interview, and I was told to prepare for the subsequent written test

It could be a little bit worse performance than getting killed or running out of HC

3.2 tencent TEG

One side

The underlying implementation of HashMap

Introduce the basic structure and compare the differences between 1.7 and 1.8

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

Whether the HashMap is thread-safe, and if you need to use it

Contrast HashMap, Hashtable, and CurrentHashMap for differences and usage scenarios

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

Let me introduce red-black trees

How It Works: Red Black Tree Portal

Application scenario: JDK1.8 HashMap, B+ tree vs. skip list

What makes Redis so fast

  • memory
  • Single thread
  • The data structure
  • IO multiplexing

Performance bottleneck (memory, network IO), can be pointed out to solve the bottleneck of network IO, in Redis 6.0 proposed single main thread, multiple worker thread design. You can compare this with the multithreaded model of memcached.

Mysql > mysql > index

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

Why choose B + tree

To introduce the difference between B + tree and B tree and compare the advantages of B + tree on disk IO (single page can store more indexes), we can mention that MongoDB uses B tree index.

Why does MongoDB index choose B tree, while MySQL index choose B+ tree

Clustered and non-clustered indexes

Reference: A brief analysis and comparison of clustered and non-clustered indexes

It was a mistake. A clustered index and a clustered index 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 datastore structure

How to design a primary key index: 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 in the form of disk mapping to solve the problem of insufficient memory when multiple processes are running at the same time.

False sharing

Pseudo-sharing principle

Can be combined with volatile and ConcurrenthashMap countercell answer

How does TCP ensure reliable transmission

  • Packet check
  • reorder
  • Discard 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 express it in your own words

The project design

Subsequent complement

Have you ever used Kafka/ES

Are you aware of the latest version of Redis (support for multi-threading)?

Pen test

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

Second interview

The biggest problem with the project (OOM) is that it will be longer

Individual analysis steps, interested can refer to. Mainly according to the theoretical basis of the analysis, and then step by step screening.

A memory leak occurs when an object allocates memory and does not recycle it after the end of the method call. The memory leak occurs when the object allocates memory and does not recycle it after the method call ends. The memory leak occurs when the object allocates memory. Our memory capacity is insufficient, resulting in insufficient memory allocation mainly from these two aspects. The first is memory overflow: our machine is configured as a 2-core 4G machine, and the heap memory is allocated as 3G, in a ratio of 1:2. Here we can view our heap memory usage through jmap-heap. Then check our GC times according to jstat -GC, we can roughly check the GC situation of our system. At that time, the FGC times we saw by analyzing the gc.log file were relatively few, so we can temporarily rule out the possibility of OOM caused by memory overflow. The second is to detect memory leaks. Is used here to - XX: HeapDumpOnOutOfMemoryError command to save oom when the stack information. The MAT tool is used to analyze memory usage. At that time, the analysis found that the Java.util. map object took up more memory. Using the MAT tool's Leak Suspects to analyze the possible causes of a memory leak. It was a method of interface to one of our student work reports. I then looked at the calls to this interface and found that the number of calls per day was around 200,000, and the average response time was around 400 milliseconds. According to the effective information analyzed, the preliminary investigation is due to the large amount of calls made by this interface, which leads to the generation of some aggregated data (mainly through the aggregation of Map). Then, due to the long response time, the object may be determined to be alive by the GC root at YGC time, and then allocated to the old age. When the method call ends, the object will live in the old age until the FGC is triggered. If it is normal, it will trigger garbage collection during FGC, not OOM. If the YGC generates a large number of live objects, but the OLDGC does not have enough memory to store these objects, it will cause OOM. Optimization process :1. JVM optimization, mainly done, one is to increase the memory, adjust the ratio of new and old (1:1), modify the garbage collector 2. Code optimization: reduce the creation of aggregated data objects, which can reduce the interface time by generating the corresponding report data in advance

Why use Redis

Middleware is introduced to solve existing problems. For example, the pressure of database access is relatively 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 about by the introduction of Redis and how they were solved. For example, it introduced how to ensure data consistency with Redis and how to ensure service availability when Redis is not available.

Improved throughput, QPS for the database

Data sensitivity is a test here, and the system is required to be tested after each change. Determine whether the change has improved service performance, by how much, where there are bottlenecks, etc

Database transactions, InnoDB index implementation principle

Transaction isolation levels and how they are implemented.

How to implement this piece needs to understand MVCC

IO multiplexing

SELECT, POLL, AND EPOLL

A further question was asked about how Epoll event notification is implemented.

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

Performance bottlenecks, how to re-optimize

The analysis mainly revolves around these three points:

  • cpu
  • memory
  • io

RPC call procedure (dubbo source code)

RPC call process this question is quite a lot, you can refer to the Dubbo architecture design, and then step by step with the source code to walk again to understand.

Why to watch: improve your coding and design skills (always look at the source code with questions, or you’ll easily forget)

Responsibilities within the team

On three sides

Job content

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

Refactoring (ideas, implementation)

Suggested reading: Refactoring — Improving the Design of Existing Code

What does performance tuning do

JVM tuning, SQL optimization/rebuild indexing, and MQ decoupling

The difference between synchronous and asynchronous

Linux IO multiplexing/AIO

Refer to interview two above

Linux select notification

B plus trees and red black trees

A HashMap the red-black tree

The way in which processes communicate

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

System performance bottleneck

The analysis mainly revolves around these three points:

  • cpu
  • memory
  • io

The results of

The interview for TEG is also N

3.3 tencent PCG

One side

How does RocketMQ guarantee reliable information

It is analyzed from three aspects: production, MQ and consumption

Message queue technology selection

Compare the characteristics of common RabbitMQ, RockerMQ and Kafka technologies, and combine the actual scenario selection of the company.

rocketmq half message

Introduces the Half Message, how to call back for failure, etc

RocketMQ consumption failed

How to solve the problem of consumption failure and the N +1 problem that consumption failure can cause

DUBBO communication process

RPC calls the procedure

Dubbo local cache address

Dubbo underlying source code

Redis cluster mode

Redis master slave synchronization

Spring transaction propagation mechanism

MySQL isolation level

Set the number of layers in the Redis skip list

The above may have more repeated content, so I did not do a detailed introduction, you can go to learn about ~

Second interview

The process of the second interview was a bit like chatting, the interviewer knew the interviewer from the other department before me (not the TEG above), so he got to know my overall situation. 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, some of which are mentioned above.

On three sides

Project introduction

The project introduction is mainly analyzed from the following aspects: 1. Business scenario 2. Performance data 3. Problems and difficulties 4
1. Business scenario

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

2. Performance data

Performance data should be the most important part of social recruitment. The interviewer will ask how the performance is in every round of interview, so we need to have a certain understanding of our system at ordinary times and know how the actual data are. Specifically including: daily visits, service QPS/TPS, the number of users and the number of machines (machine configuration) and other aspects of the data.

3. Difficulties

Here I will mainly focus on two places, one is the OOM localization processing mentioned above, the other is RocketMQ decoupling.

I introduced OOM above, and here is a brief introduction to RocketMQ in conjunction with the project.

1. Why RocketMQ was introduced? Through the pressure test of the core interface, it was found that the TPS of the interface was relatively low, and after the investigation, it was found that there were relatively many operating steps in the main process. A write request processes a lot of content, resulting in a slow response to the entire request. The throughput of the interface can be improved by splitting the core processes and auxiliary functions and performing the subsequent work in an asynchronous manner. Problems: slow response, low throughput Expectations: fast response, improved TPS Solution: Asynchronous operation/decoupling by introducing RocketMQ Message stacking, response speed, underlying language and usage scenarios are analyzed. 3. How to ensure the reliability of messages from the client, MQ and consumer end to ensure the reliability of messages. Client: Guaranteed by transaction message, or failed retry (SendResult) MQ: Guaranteed by RocketMQ cluster, mainly by Operations (may involve MQ message saving issues) 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, a round of pressure test (note that the test scenario should be consistent with the production or the last test scenario) and the consumption speed of messages (avoid the accumulation caused by too slow consumption) should be conducted after optimization. 5. Where is the performance bottleneck after optimization? Mainly from: CPU, memory and IO three aspects of the analysis, the specific system specific analysis.
4. Difficulties

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

Hr side

Job content

Team identity

Learning plan

Career planning

Individual performance

offer

Through a great deal of hardship, I finally got the offer from Tencent. Although I only wrote the interview content of two departments above, I met at least four departments (within 2 months). Therefore, there is no time well, and only carrying heavy burdens can realize my dream.

3.3 Ali ants

One side

1, Anonymous class, inner class static inner class

2. Differences between HashMap 1.7 and 1.8

3. BlockingQueue

4. The creation form of thread pool and usage scenario

5, multi-thread implementation of a counter

6, wait and notify

B+ trees and red-black trees

8. The isolation level of the database

9, database how to solve the phantom read

10, MySQL index

Redis Distributed Lock

12. Redis Sentinel cluster

13. RPC call procedure

14. How does ZooKeeper serve discovery

15. ZooKeeper heartbeat detection

In general, with the above interview process is generally similar, there is no difficulty. Therefore also do not do detailed analysis ~

Second interview

The second interview is also relatively fast, mainly two questions

Project introduction

It’s pretty much the same thing

Scenario questions

User resource permissions database design

On three sides

The three interview questions are mainly related to the business scenario and architecture, which are almost the same as the three interview questions of Tencent (in fact, because I forgot what I asked, which is mainly related to the project).

All around

The whole process lasted about 10 minutes. It was just after the headlines, so it was a bit sudden.

Project the difficulty

Problem processing

Team roles

Learning methods

Hr side

HR face a total of about 10 minutes, when the face is also a batch of panic, how so fast. The main questions asked were:

Leaving reason

Career planning

wages

offer

Finally, I successfully got the offer from ALI, so I have completed my dream! After nine spirit to walk the river’s lake ~~

4. Summary and Suggestions

In the interview process, the landlord is not smooth sailing, but also overcome difficulties. 2021 is not a stable time, and there are various changes happening every day. Only adhere to, grasp, do not give up in order to achieve their goals.

Come on, boy!