The most comprehensive Alibaba interview questions: I have taken the offer and complete Alibaba technical interview questions for the P8 position. How many can you answer these interview questions?

When we operate the database, there may be data inconsistencies (data conflicts) caused by concurrency issues. Such as

How to ensure the consistency and effectiveness of concurrent access to data is a problem that all databases must solve, and the conflict of locks is also

An important factor affecting the performance of concurrent database access, from this perspective, locks are particularly important for databases

important.

MySQL lock overview

Compared with other databases, MySQL's lock mechanism is relatively simple, and its most notable feature is the support of different storage engines

Different lock mechanisms.

such as:

The MyISAM and MEMORY storage engines use table-level locking;

The InnoDB storage engine supports both row-level locking and table-level locking, but by default

Use row-level locks.

The characteristics of the two main MySQL locks can be roughly summarized as follows:

Ali P8 Architect Talk: Features and Applications of MySQL Row Lock, Table Lock, Pessimistic Lock, and Optimistic Lock

Table-level locks: low overhead and fast locking; no deadlock (because MyISAM will obtain all the locks required by SQL at one time);

Large locking granularity, the highest probability of lock conflicts, and the lowest concurrency.

Row-level lock: high overhead, slow locking; deadlock will occur; the smallest locking granularity, the lowest probability of lock conflicts, and the degree of concurrency

Ya is the best.

Page locks: The overhead and locking speed are between table locks and row locks; deadlocks will occur; locking granularity is between table locks and row locks,

Average concurrency

Row locks and table locks

1. Mainly divided into lock granularity, generally divided into: row lock, table lock, library lock

(1) Row lock: When accessing the database, the entire row data is locked to prevent concurrent errors.

(2) Table lock: When accessing the database, the entire table data is locked to prevent concurrent errors.

2. The difference between row lock and table lock:

Table lock: low overhead, fast locking, no deadlock; high locking strength, high probability of lock conflicts, and lowest concurrency

Row locks: high overhead, slow locking, and deadlock; small locking granularity, low probability of lock conflicts, and high concurrency

Pessimistic lock and optimistic lock

(1) Pessimistic lock: As the name implies, it is very pessimistic. Every time you get data, you think that others will modify it, so every time

When taking data, it will be locked, so that others who want to take this data will block until it gets the lock.

Many such locking mechanisms are used in traditional relational databases, such as row locks, table locks, etc., read locks, write locks, etc.

It is to lock first before doing the operation.

(2) Optimistic lock: As the name suggests, it is very optimistic. Every time I get data, I think that others will not modify it, so I don’t

It will be locked, but during the update, it will be judged whether someone else has updated the data during this period. You can use the version

Number and other mechanisms. Optimistic locking is suitable for multi-read application types, which can improve throughput, like a database if it provides similar

The write_condition mechanism is actually the optimistic lock provided.

(3) The difference between pessimistic lock and optimistic lock:

Both types of locks have their own advantages and disadvantages. One cannot be considered as better than the other. For example, optimistic locks are suitable for less write situations, that is, conflicts.

When it happens rarely, this saves the overhead of locking and increases the overall throughput of the system. But if often

If conflict occurs, the upper application will continue to retry, which actually reduces performance, so in this case, use pessimistic lock

Is more appropriate.

Shared lock

Shared lock refers to sharing the same lock on the same resource for multiple different transactions. Equivalent to the same door,

It holds multiple keys the same. Just like this, your house has a gate, and there are several keys to the gate. You have one, your daughter

Friends have one, and you can all enter your home through this key. This is the so-called shared lock.

As I just said, for pessimistic locks, general databases have been implemented, and shared locks are also a kind of pessimistic locks, so shared locks

What command is used to call it in mysql. By querying the information, I learned that by adding lock after the execution statement

In share mode means adding a shared lock to some resources.

When to use table locks

For InnoDB tables, row-level locks should be used in most cases, because transactions and row locks are often the reason we

Reasons for choosing InnoDB tables. But in individual special affairs, you can also consider using table-level locks.

The first situation is: the transaction needs to update most or all of the data, and the table is relatively large. If the default row lock is used, no

Only this transaction execution efficiency is low, and may cause other transactions to wait for a long time and lock conflicts, in this case can be considered

Consider using table locks to improve the execution speed of the transaction.

The second situation is: the transaction involves multiple tables, which is more complicated, and is likely to cause deadlock and cause a large number of transaction rollbacks. This kind of

The situation can also consider one-time locking of the tables involved in the transaction to avoid deadlocks and reduce the database open due to transaction rollbacks.

pin.

Of course, these two types of transactions cannot be too many in the application, otherwise, you should consider using MyISAM tables.

Table lock and row lock application scenarios:

Table-level locks are not used and concurrency is not high, and are mainly query-based applications with few updates, such as small web applications;

Row-level locks are suitable for systems that require high transaction integrity in a high-concurrency environment, such as online transaction processing systems.

BAT technical interview scope

Data structure and algorithm: the most common sorts, preferably handwritten

Java advanced: JVM memory structure, garbage collector, collection algorithm, GC, concurrent programming related (multiple

Threads, thread pools, etc.), NIO/BIO, and the comparative advantages and disadvantages of various collections (the underlying data structure should also

Master, especially expansion, etc.) etc.

Performance optimization, design patterns, mastery of UML

Spring framework: focus on mastering (BAT must ask every time)

Distributed related: Redis cache, consistent Hash algorithm, distributed storage, load balancing, etc.

Microservices and Docker containers, etc.

 

 

 

 

 

 

 

 

 

 

 

Ali interview summary

Ali’s interviews particularly like the technical principles of the interview , especially, multi-threading, NIO, asynchronous messaging framework, distributed-related caching algorithms, etc., JVM loading process and principles, recycling algorithms, and specific used frameworks. Some parameters will be asked Check if you are familiar

If you pass the first side, the possibility of subsequent employment is higher. The first round is very important. It is recommended to study the interview questions systematically!

one side:

  1. HashMap realization principle, ConcurrentHashMap realization principle
  2. Red-black trees, why are local imbalances allowed
  3. The difference between TCP and UDP, why is it reliable and unreliable
  4. The whole process of an HTTP request, including domain name resolution, host locating, etc.
  5. TCP three-way handshake
  6. What is MySQL transaction? Four characteristics, four isolation levels
  7. The difference between ConcurrentHashMap and Hashtable
  8. spring IOC and AOP, and what are the advantages of each
  9. What are the commonly used thread pools
  10. When to use Runnable and Thread to create threads, the difference between Runnable and Callable
  11. How to handle the exception in the thread method, can the secondary thread catch it
  12. The difference between synchronized and lock, when to use synchronized and ReentrantLock
  13. JVM objects are allocated in which area and Class objects are allocated in which area

Two sides:

  1. Introduction to commonly used design patterns: singleton pattern, decorator pattern, etc.
  2. Will Java overflow? Under what circumstances will it appear?
  3. The parent delegation model, why do this?
  4. When does the subject enter the old age?
  5. Quick sort talk about the process
  6. AOP realization principle: dynamic proxy
  7. BIO, NIO (how to achieve), AIO
  8. What are the message middleware? The advantages and disadvantages between them?
  9. Redis, the persistence framework
  10. Stack and queue
  11. Garbage collection algorithm
  12. MySQL index
  13. Tomcat class loader
  14. OOM memory leak, under what circumstances, how to troubleshoot

Three sides:

  1. Introduce your practical performance optimization cases and your optimization ideas
  2. The difference between microservices and SOA, advantages and disadvantages
  3. SQL slow query optimization plan, index and table optimization plan.
  4. The difference between MySQL and MongoDB, the storage of massive data
  5. Cache framework, such as the difference between Redis and Memcached, comparison of advantages and disadvantages
  6. Please describe the consistent hash algorithm
  7. What are the sharing schemes of distributed session and what are the advantages and disadvantages
  8. High concurrency, what are the optimization schemes of the system, and prioritization.
  9. Interview summary

Four sides:

  1. The difference between ArrayList and linkedlist. Whether the ArrayList will be out of bounds.
  2. What is the difference between ArrayList and hashset. Is the number stored in hashset ordered?
  3. The difference between volatile and synchronized
  4. The principle of polymorphism
  5. The difference between the database engine Innodb and myisam
  6. Redis data structure
  7. Is Redis memory-based?
  8. The underlying implementation of Redis's list zset
  9. The difference between http and https, tcp handshake process
  10. jvm garbage collection algorithm handwritten bubbling
  11. Handwritten singleton includes multithreading
  12. How to achieve synchronization between Java threads, the difference between notify() and notifyAll()
  13. Application scenarios of pessimistic locking and optimistic locking of the database.
  14. The complexity of the sorting algorithm, quick sort is implemented non-recursively.
  15. Mass data filtering, blacklist filtering a url.

Five sides:

  1. What are the typical implementations of the underlying implementation of list set map
  2. How does hashmap expand and why is it a power of 2
  3. Why concurrenthashmap is thread safe and what measures have been taken to deal with high concurrency
  4. What is the meaning of the thread pool parameters
  5. Springmvc request process
  6. Spring IOC, how autowired is implemented
  7. Spring boot
  8. The basic architecture design of SpringClound
  9. What is the difference between Dubbo and SpringClound, advantages and disadvantages
  10. Talk about the consistent Hash algorithm

Six sides:

  1. Which aspect of distributed architecture design is more familiar
  2. Tell me about your understanding of CDN, the difference between distributed cache and local cache
  3. What is the difference between multithreading and high concurrency
  4. What are the commonly used technical solutions under high concurrency? Give three high concurrency scenarios design examples
  5. Talk about a practical case of your JVM optimization, including practical steps and methods
  6. Have you used and understood Docker? What is the difference between Docker and JVM?
  7. The basic architecture and usage scenarios of Docker?
  8. Which open source frameworks has load balancing been exposed to, and what are the advantages and disadvantages?
  9. How to implement database sub-database sub-table?
  10. Common optimization strategies on the database side?
  11. If you are asked to design the spike system, what is your design idea and why do you design it like this?

Interview summary:

The basic knowledge points of java mainly revolve around collection classes and multithreading: the data results of ArrayList, LinkedList, HashSet, HashpMap, how to expand, and ConcurrentHashMap related multithreading safety.

JVM memory allocation, several common garbage collection algorithms and principles, and corresponding JVM optimization parameters need to be kept in mind.

Network: TCP's three-way handshake and other networks must be asked, focusing on mastering the network protocol.

Redis: As the main force of distributed caching, it is basically a must-test for BAT every time. The focus is on Redis's data structure, memory,

Algorithms, persistence, and the advantages and disadvantages of memcached and other caches.

Multithreading: state flow, realization of multithreading, and the difference with high concurrency, etc.

The Spring framework asks the most, and BAT likes to ask very much, focusing on mastering.

Finally, the distributed architecture design

Commonly used distributed architecture design solutions: single sign-on, distributed cache, storage, message selection, and data

The optimization plan of the library side (need to know in advance).

It’s best to understand in advance a project like spike, if the interviewer asks about a similar project, you can design

Put your ideas out, this is a big plus for your interview results.

one side

1. Introduction

2. Talk about a project that you think you have learned the most, what technologies have been used, and where are the challenges 3. Scope of Spring beans? (For example: singleton, prototype, etc.)

4. How does Spring implement IOC? Can no parameterless constructor be instantiated? Parameter constructor injection? (Xml configuration)

5. Through reflection, talked about the method area, and then, the class loading mechanism?

6. The realization principle of synchronized? Can Volatile guarantee atomicity? why?

7. How to realize the size method of hashmap and concurrenthashmap

8. Tuning parameters of JVM? (-Xmn, -Xms and other specific parameter settings)

9. Thread pool advantages, parameters, if I want to implement newSingleThreadPoll, how should I configure it, and what construction method should I pass in?

parameter

10. How to solve the mysql deadlock, if the execution order is not required, how to solve the deadlock

11. The principle of ioc and aop

12. The five states of threads? Conversion process?

13. TCP three-way handshake, why three-way handshake?

14. JVM memory partition? (Main memory, working memory, heap, stack...)

15. Tell me about GC?

16. Why use the old and new generations?

17. What happens when the new generation enters the old generation?

18. The partition of the new generation?

Two sides

  1. Changed the method and asked a lot of thread pool knowledge (mainly examines the corresponding parameters)
  2. java memory model
  3. The difference between lock and synchronized
  4. Implementation of reentrantlock
  5. hashmap 和 concurrenthashmap
  6. The difference between B+ tree and B- tree
  7. Compound index
  8. The difference between clustered index and non-clustered index?
  9. What is the difference between a database index primary key and a unique index? Index failure conditions and when to create an index
  10. The difference between innDB and MyISAM?
  11. Thread safety (blocking synchronization, non-blocking synchronization, no synchronization)

Three sides

  1. Mainly high concurrency and distributed architecture design
  2. Server model and the difference between
  3. Thread pool design
  4. How to load balance the thread pool
  5. How to implement thread scheduling algorithm
  6. How is the composite index implemented?
  7. How to design single sign-on, the principle of single sign-on
  8. The difference between redis cache and memcached cache, and their advantages and disadvantages
  9. How to optimize the performance of large-scale high-concurrency websites: Web performance, database performance, application server performance, etc.
  10. How to optimize MySQL in practice: optimization of SQL statements and indexes, optimization of database table structure, optimization of system configuration,
  11. Hardware optimization
  12. How to design sub-database sub-table and read-write separation
  13. Microservice architecture: the difference between dubbo and springcloud, and their corresponding usage scenarios.

Taobao side:

Interview introduction

1) Introduce yourself?

2) Project introduction?

3) What is the biggest difficulty encountered? How to solve it?

4) How do you think you can optimize this project?

Interview questions

1) Talk about JVM

2) Talk about JVM's generational collection and specific algorithms

3) Looking at the garbage collector of JVM, what is the difference between G1 and CMS?

4) Tell me about the process of a variable from its generation to its end, and about the process of string constants?

5) What causes the thread safety problem?

6) Talk about optimistic locking and pessimistic locking 7) How does optimistic locking ensure consistency

8) What is the difference between Integer and int? What are the special functions in integer?

9) Talk about the isolation level of the database

10) Talk about MVCC

11) What is the difference between a clustered index and a non-clustered index

Taobao two sides:

1. Ask about bubble sorting, fast sorting, merge sorting, advantages and disadvantages and optimization

2. There are seven layers of osi and five layers of tcp/ip in the network, what are the protocols and functions

3. What data structure does the crawler use?

4. TCP flow control and congestion control

5. What storage engine does mysql use, what data structure does this storage engine use, what are the advantages and disadvantages, and how to use it

6, JVM garbage collection mechanism and garbage collector

7. The isolation level of things in spring

8. New features of jdk1.8 concurrenthashmap, have you seen the source code?

9. Do you understand threadlocal?

10. I asked some questions about redis, including (capacity expansion, invalid key cleaning strategy, etc.)

11. The rest are the things of the project (kafka filebeat elk principle, master-slave election, replication, etc.)

12. I asked about some big data related to the extended later, and asked me if I have any understanding of some big data processing frameworks

The whole process is about forty minutes

Taobao three sides

Main projects, what projects have you done and what technologies have you used? What frameworks do you understand? What do you think improves your skills the most is

Which thing has improved your skills?

1) Talk about the underlying implementation of Spring AOP and IOC

2) Tell me about the role of hashcode? The underlying implementation of HashMap? The difference between HashMap and HashTable 3) Tell me about the difference in performance between concurrentHashMap and hashTable? And the reason for this difference

4) Talk about heap and heap sort

5) Tell me about the difference between B+tree and binary search tree? Talk about the difference between binary search tree and AVL tree, red-black tree

6) Give you two files (in string form) how to find the difference between them?

7) How can you optimize what you just said?

Taobao four-sided intersection

I thought that the end of the three sides would be the hr side, but I received another cross

1. Give you 5 billion lines of character string, machine 4G memory (only one machine), find the line of character string that repeats the most times?

(In line units, no more than 10 characters per line)

2. Design an algorithm to realize that two large files of 10g can be repeatedly placed in the third one in the memory of 10m.

file

3. How complicated is the average quicksort? What is the worst case? (This question is probably to ease the awkward atmosphere)

Alipay side

4. Introduce yourself.

5. What are the core designs involved in the project

6. ArrayList and LinkedList bottom layer

7. HashMap and thread-safe ConcurrentHashMap, and their advantages and disadvantages

8. How Java achieves thread safety

9. Which is better, Synchronized or Lock?

10. How is the get() method in HashMap implemented?

11. What scenarios can HashMap be used in?

12. JVM, garbage collection mechanism, memory division, etc.

13. SQL optimization, commonly used index?

14. What more questions need to be asked.

Alipay two sides

16. Without self-introduction, just ask what Java development-related projects you have done.

17. Which technologies are you familiar with?

18. Multithreaded state diagram, how does the state flow?

19. Deadlock, the cause of deadlock

20. Page lock, optimistic lock, pessimistic lock?

21. How does optimistic locking ensure thread safety?

22. Have you used the thread pool, the corresponding benefits, and how to use it?

23. Two 10G files, there are some URLs, and the memory is only 1G, how to merge these two files and find the same

The url?

24. 1000 multiple concurrent threads, 10 machines, each with 4 cores, design thread pool size. 25. Code problem: Two ordered arrays, there are duplicate numbers in the array, merge them into an ordered array, and remove the duplicate numbers.

26. Talk about your strengths.

Alipay three sides

28. What has been done in jvm performance tuning

29. How to do database performance tuning

30. Principles of distributed systems: CAP, final consistency, idempotent operations, etc.

31. In the case of high concurrency, how does our system support a large number of requests?

32. How the cluster synchronizes session state

33. Commonly used NOSQL, have you compared it?

34. Under what circumstances will avalanches occur, and how to deal with them?

35. Principles of Load Balancing

36. Database Transaction Properties

The above is the complete Alibaba technical interview questions and a summary of Alibaba interview experience, I hope it will help you!

Interview answer!

The answers to the interview have been sorted out. The position for this technical interview is Ali P8. You can compare it!

Alibaba interview questions: complete Alibaba technical interview questions for P8 positions

äºé ¢ é¿éææ¯ä¸å®¶å²ï¼å · ²æ¿offerï¼è¿äºé ¢ è¯é ¢ ä½ è½çåºå¤å °

äºé ¢ é¿éææ¯ä¸å®¶å²ï¼å · ²æ¿offerï¼è¿äºé ¢ è¯é ¢ ä½ è½çåºå¤å °

Guess you like

Origin blog.csdn.net/AI_mashimanong/article/details/109334046