5-sided Ant Financial, 3-sided Pinduoduo, 2-sided byte beating, share the experience of abuse, have already got an offer from Ants!

Ant Financial

one side

At the same time, I did an algorithm problem and required it to be completed within two hours. I gave an array of length N with repeated elements and asked to output the 10th largest number. The typical TopK problem is solved by the quick sorting algorithm.

Algorithmic questions should pay attention to the legality check, boundary conditions and abnormal handling. In addition, if you want to write test cases, you must ensure that the test coverage scenarios are as complete as possible. In addition to the usual brushing algorithm questions, this kind of assessment should be no problem.

Due to the limitation of the length of the article, it is impossible to display all the interview questions in text form. This article selects some interview questions for everyone

A lot of support, you can get information for free-after three consecutive years (promise: 100% free)

Quick start channel: ( click here ) to download! Full of sincerity! ! !

Two sides

  • Self introduction
  • Have you contributed code to an open source project? (Dubbo mentioned a bug that prints accesslog?)
  • What are you doing in the department at present, what are the internal systems, functions and interaction processes under a brief introduction to the business?
  • What pits have Dubbo stepped on and how did they solve them? (Said the problem of business exception capture during exception handling, and customized an exception interceptor)
  • Begin to get into the topic and talk about your understanding of thread safety (multithreaded access to the same object, if you don’t need to consider additional synchronization, the behavior of calling the object can get the correct result is thread safety)
  • What are the characteristics of transactions? (ACID)
  • How to understand atomicity? (Under the same transaction, multiple operations either succeed or fail, and there is no partial success or partial failure)
  • The difference between optimistic lock and pessimistic lock? (Pessimistic lock assumes that conflicts will occur, and locks must be acquired first when accessing to ensure that only threads acquire the lock at the same time, and reads will also block; optimistic locks assume that there will be no conflicts, and only check if there is a conflict when submitting the operation ) How are these two locks implemented in Java and MySQL? (Java optimistic lock is implemented through CAS, and pessimistic lock is implemented through synchronize. MySQL optimistic lock is implemented through MVCC, which is the version, and pessimistic lock can be achieved through select... for update plus exclusive lock)
  • Why is HashMap not thread-safe? (Multi-threaded operation has no concurrency control. By the way, multi-threaded access will cause deadlock during expansion, and a loop will be formed. However, the problem of multi-threaded operation forming a loop during expansion has been solved in JDK 1.8, but under multi-threading Using HashMap will also have some other problems such as data loss, so HashMap should not be used in multi-threading, but ConcurrentHashMap should be used) How to make HashMap thread safe? (The synchronize method of Collections wraps a thread-safe Map, or directly uses ConcurrentHashMap) What is the difference between the two? (The former directly adds synchronize to the put and get methods, while the latter uses segmented locks and CAS supports higher concurrency)
  • What optimizations has been made to ConcurrentHashMap in jdk1.8? (If the red-black tree is used for the array element when inserting, the segmented lock design is cancelled, and synchronize replaces the Lock lock) Why is this optimized? (Avoid how long the linked list is when the conflict is serious, improve query efficiency, and increase the time complexity from O(N) to O(logN))
  • Do you understand the redis master-slave mechanism? How did it happen?
  • Have you had any experience in GC tuning?
  • Is there anything you want to ask?

Three sides

  • Briefly introduce yourself
  • How does the monitoring system work, which modules are divided into, and how do the modules interact? What database is used? (MySQL) What storage-engine is used, and why use InnnoDB? (Support transaction, clustered index, MVCC)
  • Is the order form split? How to split it? (Vertical split and horizontal split)
  • The query process description after horizontal split
  • What if the data that falls into a certain shard is large? (According to certain rules, such as hash modulus, range, split a single table into multiple tables)
  • Is there any problem with hash modulus? (Yes, the data is unevenly distributed, and expansion and contraction are relatively complicated)
  • How to solve the reading and writing pressure after sub-database sub-table? (One master and multiple slaves, multiple masters and multiple slaves)
  • How to ensure that the primary key is unique after splitting? (UUID, Snowflake algorithm)
  • Is the ID generated by Snowflake globally incremented and unique? (No, it's only globally unique, single machine increments)
  • How to achieve a globally incremented unique ID? (Talking about TDDL's method of taking a batch of IDs at a time, and then slowly assigning them locally)
  • Let's talk about the index structure of Mysql (Speaking of B+ tree, B+ tree can search for leaf nodes in order, because leaf nodes store data nodes and are ordered)
  • The difference between a primary key index and an ordinary index (the leaf node of the primary key index stores the entire row of records, and the leaf node of the ordinary index stores the primary key ID. When querying, you need to do a table query). Do you have to query the table? (Not necessarily, when the query field happens to be the indexed field or part of the index, you don't need to return to the table, which is also the principle of index coverage)
  • Where is the current bottleneck of your system?
  • How do you plan to optimize? Briefly talk about your optimization ideas
  • Is there anything you want to ask me?

All sides

  • Introduce yourself
  • Why do reverse engineering?
  • How to understand microservices?
  • How is service governance achieved? (Talking about the realization of current limiting, pressure measurement, monitoring and other modules)
  • Isn't this something middleware does? Why does your department do it? (There was no separate middleware team at the time, and microservices were just launched soon, and monitoring and performance optimization were needed)
  • Talk about the life cycle of Spring
  • Talk about the GC process (talking about the trigger conditions and recycling process of young gc and full gc and the process of object creation)
  • What's wrong with CMS GC? (Concurrent cleaning algorithm, floating garbage, short pause)
  • How to avoid floating garbage? (Remember that there is a VM parameter setting that allows the young gc to be performed once before scanning the new generation, but because gc is automatically scheduled by the virtual machine, it is not guaranteed to be executed. However, there are parameters that allow the virtual machine to force the young gc to be executed once)
  • What's the problem with forcing young gc? (STW pause time becomes longer)
  • Do you know G1? (Learn a little bit)
  • What is the recycling process? (young gc, concurrent phase, mixed phase, full gc, said Remember Set)
  • How is the bottom layer of Remember Set you mentioned?
  • Is there anything you want to ask?

Five sides

Five aspects are for HRBP. They mainly talked about the previous internship experience at Ant, what the department is doing, career development, welfare benefits, etc. Ali interviewers do have one-vote veto power, and they value whether your values ​​match or not, and generally prefer candidates who are honest. HR must be honest, don’t lie, as long as you lie, HR will verify it and cut it directly.

  • Who was the supervisor during the internship?
  • What did the internship do?
  • What do you think of technology? What technology stack do you usually use?
  • Have you been researching anything recently?
  • What do you think of SRE
  • Do you have any expectations for the treatment?

summary

Ant interviews pay more attention to the basics, so the basic skills of Java must be solid. Ant's working environment is quite good, because I am in front of the stability assurance department, and there are many separate groups, like Class 1 for three years, which is very youthful. The basic level of the interviewers is relatively high, basically P7 or above, in addition to the basics, they also asked a lot of questions about the architecture design, and the harvest was quite big.

Pinduoduo

one side

  • Explanation of HashMap and TreeMap in Java? (TreeMap red-black tree, ordered, HashMap unordered, array + linked list)
  • What is the time complexity of TreeMap query writing? (O(logN))
  • What's wrong with HashMap multithreading? (Thread safety, deadlock) How to solve it? (Synchronize + CAS is used in jdk1.8. When expanding the capacity, use CAS to check if there are any changes. If it is, try again.) Will there be any problems in retrying? (CAS (Compare And Swap) is comparison and exchange, it will not cause thread blocking, but because the retry is achieved through spin, it will still take up CPU time, and there is also the problem of ABA) How to solve it? (Timeout, limit the number of spins, ABA can be solved by the principle variable AtomicStampedReference, the principle uses the version number for comparison) What if the number of retries is exceeded and it still fails? (synchronize mutex lock)
  • What is the difference between CAS and synchronize? Isn't it possible to use synchronize? (CAS is optimistic lock, does not need to be blocked, the atomicity achieved at the hardware level; synchronize will block, the atomicity achieved at the JVM level. Different usage scenarios, when the thread conflict is serious, CAS will cause excessive CPU pressure, resulting in a decrease in throughput, synchronize The principle is to spin first and then block. The thread conflicts are serious and there is still a higher throughput, because the threads are blocked and will not occupy the CPU)
  • What if you want to ensure thread safety? (ConcurrentHashMap)
  • How does ConcurrentHashMap achieve thread safety? (Segment lock)
  • Does get need to be locked and why? (No, volatile keyword)
  • What is the role of volatile? (Guaranteed memory visibility)
  • How is the bottom layer implemented? (Talking about main memory and working memory, read-write memory barrier, happen-before, and draw thread interaction diagram on paper)
  • How to ensure visibility under multi-core CPUs?
  • Talking about the project, how do the systems interact?
  • How much concurrency is in the system and how to optimize it?
  • Give me a piece of paper, draw a nine squares, fill in the numbers, give an MN matrix, and print the MN numbers counterclockwise starting from 1, requiring the time complexity to be as low as possible
  • You can first talk about your thoughts (remembered, when did you say the conditions for changing directions, right, down, left, up, and so on)
    . What do you want to ask me?

Two sides

  • Introduce myself
  • Do you have any other offers? (Take the offer of ants)
  • What is the organizational structure of the department?
  • What are the modules in the system, what technologies are used in each module, and how does the data flow? I was given a piece of paper, and I briefly drew the flow between systems on it
  • How is the link tracking information transmitted? (The attachment of RpcContext talks about the structure of Span: parentSpanId + curSpanId)
  • How does SpanId guarantee uniqueness? (UUID, talked about internal customization changes)
  • In what dimension is RpcContext passed? (Thread)
  • How is Dubbo's remote call implemented? (Talking about the process of reading configuration, assembling url, creating Invoker, service export, service registration, and consumers through dynamic proxy, filter, obtaining Invoker list, load balancing, etc.
  • How is Spring's singleton implemented? (Singleton Registration Form)
  • Why implement a service governance framework separately? (Said that the internal microservices have just been launched soon, mainly for some monitoring and performance optimization of the services)
  • Who is leading? Is it still in use internally?
  • Have you ever thought about how to make it universal?
  • Is there anything you want to ask?

Three sides

After the face of the second boss, he directly interviewed the HR, mainly asking about career development, whether there are other offers, and the intention to enter the job. By the way, the company's benefits and benefits are more conventional. But what I have to say is that if you have other offers or experience with big factories, you will get some bonus points.

summary

Pinduoduo's interview process is much simpler, after all, it is a company that has been established for more than three years. The difficulty of the interview is moderate, as long as the foundation is solid, it shouldn't be a problem. But I have to say that the work intensity is very high. Before the start of the interview, HR confirmed with me in advance whether I can accept such an intense work. The old iron who wants to come must be prepared.

Byte beating

one side

  • Introduce yourself first
  • Talk about the project, what does the reverse system mean
  • Talk about the project, what technologies are used in the reverse system
  • How to determine the number of threads in the thread pool?
  • How to determine if it is mainly IO operation?
  • How to determine if computational operations?
  • Are you familiar with Redis, and what data structures do you know? (Said zset) How is the bottom layer of zset implemented? (jump table)
  • What is the query process of the jump table, and the time complexity of query and insertion? (Speaking of searching from the first layer, if not satisfied, sink to the second layer to find, because each layer is in order, write The time complexity of entry and insertion are both O(logN))
  • Do you understand the red-black tree, the time complexity? (Said it is an N-ary balanced tree, O(logN))
  • Since the time complexity of the two data structures is O(logN), why does zset not use red-black trees (jumping tables are simple to implement, and the cost of stepping on pits is low, and the red-black tree must be rotated every time it is inserted to maintain balance, which is complicated to achieve)
  • I nodded and talked about the principle of Dubbo? (Talking about the process of service registration and release and consumer invocation) Have you stepped on any pits? (Talking about dubbo exception handling and printing accesslog issues)
  • Does CAS understand? (Talking about the realization of CAS) Do you know other synchronization mechanisms? (Talking about synchronize and the difference between the two, an optimistic lock, a pessimistic lock)
  • Let's do a problem, array A, 2*n elements, n odd numbers, n even numbers, design an algorithm so that the odd numbers in the array are all odd numbers, and the even numbers are even numbers.
  • Let me talk about your idea first (start traversing from 0 subscript, if it is an odd subscript to determine whether the element is odd, skip it, otherwise look for the next odd number from this position)
  • The next odd number? How to find?
  • Any ideas? (It is still to traverse the array once and judge the subscript. If the attribute of the subscript does not match the element at the position, traverse the array element next to the current subscript, and then replace it)
  • Your time complexity is a bit high. If you require O(N), what should you do (think about it for a while, and answer "Define two pointers, start traversing from subscripts 0 and 1, respectively. When encountering odd numbers, the position is even and the even number is odd. Just stop and exchange content")
  • Time is almost up, let's get here first. What do you want to ask me?

Two sides

  • You introduce yourself first
  • How do you understand service governance?
  • How to achieve the current limit in the project? (Guava ratelimiter, token bucket algorithm)
  • How does it work? (The main point is that the rate is fixed and the number of tokens is limited)
  • If suddenly many threads request tokens at the same time, what's the problem? (Resulting in a lot of request backlogs and thread blocking)
  • How to solve it? (You can put the backlog of requests in the message queue and process them asynchronously)
  • What if I don't use the message queue? (Talking about RateLimiter's pre-consumption strategy)
  • How is the context of distributed tracing stored and transferred? (ThreadLocal + spanId, the spanId of the current node is used as the parent spanId of the next node)
  • How is Dubbo's RpcContext passed? (ThreadLocal) How to pass the ThreadLocal of the main thread to the thread pool? (Said that the context information is first obtained in the main thread through the get method of ThreadLocal, and a new ThreadLocal is created in the thread pool and the previously obtained context information is set to the ThreadLocal. Note that the ThreadLocal created by the thread pool must be manually created in the finally remove, otherwise there will be memory leaks)
  • How exactly did the memory leak you mentioned happen? (Speaking of the structure of ThreadLocal, there are mainly two scenarios: the main thread still has a reference to ThreadLocal and the main thread does not have a reference to ThreadLocal. In the first scenario, because the main thread is still running, there is still a reference to ThreadLocal, then The reference and value of the ThreadLocal variable will not be recycled. In the second scenario, although the main thread does not have a reference to ThreadLocal, and the reference is a weak reference, it will be recycled at the time of gc, but the value used is not weak Reference, will not be reclaimed by memory, and still cause memory leak)
  • Does the thread of the thread pool have to manually remove to reclaim the value? (Yes, because the core thread of the thread pool always exists, if it is not cleaned up, the threadLocals variable of the core thread will always hold the ThreadLocal variable)
  • Then you mean the memory leak refers to the main thread or the thread pool? (Main thread)
  • But the main thread has not all exited, shouldn't the referenced objects be recycled?
  • So how do you tell SpringMVC different user login information to ensure thread safety?
  • Isn't it enough to use ThreadLocal directly? Have you seen any code that implements a lock in SpringMVC?
  • Let's talk about mysql, let's talk about the index structure (B+ tree)
  • Why use B+ tree? (Speaking of high query efficiency, O(logN), you can make full use of the characteristics of disk read-ahead, multi-branch tree, small depth, orderly leaf nodes and store data)
  • What is index coverage?
  • Why does Java design a parent delegation model?
  • When do you need a custom class loader?
  • Let's do a problem, handwriting an object pool
  • Is there anything you want to ask me?

summary

Toutiao’s interview is indeed very professional. Every time the interviewer will send you a video link in advance, and then start the interview on time, and the inspection locations are relatively complete.

Interviewers have a characteristic, they will grasp a point worthy of in-depth or you did not make it clear and go deep until you make this point clear, otherwise the interviewer will feel that you don't really understand it. The second interviewer gave me some suggestions. When researching technology, we must study the background and figure out what specific problems are solved in which scenarios. In fact, many technologies are interlinked internally.

to sum up

Two things should be done before the interview: resume and self-introduction. The resume should be a good review of some of the projects that you have done, and then select a few highlight projects. Self-introduction is basically available in every round of interview, so it’s best to practice in advance and figure out what to say and how to say it separately. In addition, the technology mentioned in the resume must have been researched in depth by myself. If there is no in-depth research, it is best to find some information to warm up and not fight unprepared battles.

Thank you for seeing here, I am a programmer Maidong , a java development practitioner , I have been in the industry for six years, and I share java-related technical articles or industry information every day

Welcome everyone to follow and comment on the article, and quickly receive the channel: ( click here ) to get it for free! Full of sincerity! ! !

Guess you like

Origin blog.csdn.net/weixin_47066028/article/details/109528125