2019 ants gold dress Java will ask interview questions (two faces)

2019 ants gold dress Java will ask interview questions (two faces)
Two faces

Do you have any questions to ask me?

1, self-introduction, work experience, technology stack

2. What did you learn project technology?

3, micro-services division of granularity?

4, how to ensure high availability of micro-services?

Load balancing and reverse proxy, isolation, current limiting, demotion, timeout and retry, rollback, stress testing and contingency plans

5, the commonly used load balancing, how to use, you can say under it?

(1) http redirection

When the http proxy (such as a browser) requests a URL to a web server, web server can be returned by a new URL http response header information Location mark. This means that the HTTP proxy need to continue to request the new URL, complete the automatic jump.

(2) DNS load balancing

DNS is responsible for providing DNS service, when accessing a site, you first need to actually obtain the IP address of the DNS server points to the DNS domain name of the site, in the process, the DNS server to complete the domain name to IP address mapping, Again, this mapping can also be one to many, this time, DNS server will act as a load balancer scheduler, it's like http redirection conversion strategy, as the user requests across multiple servers, but its implementation the mechanism is completely different.

(3) IP load balancing (LVS-NAT)

Because the reverse proxy server is working in the HTTP layer, the overhead itself has severely restricted the scalability, which also limits its performance limits. That it can achieve load balancing at HTTP level or less?

NAT server: it works at the transport layer, which may modify the IP packet transmitted, the destination address of the packet to modify the actual server address

(4) direct route (LVS-DR)

NAT is working in a network transport layer hierarchical model (fourth layer), and direct routing works at the data link layer (second layer), some seemingly more cock. It (not modified target IP) by modifying the destination MAC address of the packet, forwards the packet to the server on the real difference is the actual server response data packet will be sent directly to the customer carbonyl, without passing through the scheduler

(5) IP tunnel (LVS-TUN)

Transfer request based on IP tunneling mechanisms: the IP packet is encapsulated in the scheduler receives a new IP packet, transferred to the actual server, then the actual server response packet directly to the client can be. At present, most Linux support, can be implemented by LVS, called LVS-TUN, and LVS-DR is different, and the scheduler server may actually not in the same network segment WANt, forward the request to the scheduler by the actual IP tunneling server , so the actual server must also have a valid IP address.

Overall, LVS-DR and LVS-TUN are suitable asymmetric response and request a Web server, how to make a choice from them, depending on your network deployment needs, because the LVS-TUN actual server can be deployed as needed different regions, and to transfer the request based on the principle of the nearest access, it is similar to this demand, it should be selected LVS-TUN.

6, what benefits can bring the gateway to back-end services?

Back-end server can concentrate on business request and save a lot of overhead connection management

7, object comparison is the same

equals commonly used to compare the contents of two objects are equal, == addresses used to compare two objects are equal

8, when hashmap put method of how to determine whether the deposit is repeated

Comparison of the hashCode first key, and then compare equal to or equals, the rewrite hashCode () and equals () method may be repeated to add elements to achieve.

9, Set List, and the difference?

Set (set): A collection of objects are not sorted in a specific manner, and no duplicate object. Some of its implementation class can sort the objects in the collection in a particular manner.

List (List): the set of objects sorted by the index position, the object can be repeated, according to the object allows the search target index position in the collection.

10, ArrayList and LinkedList difference

ArrayList data structure is implemented based on dynamic array, LinkedList based linked list data structure

ArrayList inherited AbstractList

LinkedList inherits AbstractSequentialList

ArrayList uses an array to store the object, this approach placing objects successive positions, so the biggest drawback is very troublesome when inserting deleted

The object is stored in a separate space, but in each case also save space in a linked index LinkedList used but the drawback is very troublesome to find the first index began to clump

11, if access to the same data, ArrayList and LinkedList who take up more space?

For random access get and set, ArrayList feel better than LinkedList, because LinkedList To move the pointer

For new and delete operations add and remove, LinedList comparative advantage, because ArrayList to move data, to delete or insert an object from the array, the array elements required after the mobile segment, which will re-adjust the order of the index, the index adjustment the order will consume a certain amount of time, on the contrary, LinkedList is implemented using a linked list, to remove or insert an object from the list, just change the subject before and after the reference to

12, HashTable you find out about it?

Hashtable neither supports nor Null key support Null value. Notes Hashtable's put () method in a note Hashtable is thread-safe,

Hashtable is thread-safe, it's each method are added to the Synchronize method, efficiency is relatively low

Hashtable default initial size is 11, after each expansion, the capacity of the original becomes 2n + 1.

Hashtable when the position of the element needs to be a division calculation, and the division is more time-consuming.

13、synchronized、lock

synchronized is a keyword in java, that is the Java language built-in features

If a synchronized block of code is modified, and when one thread acquires the corresponding lock, and executes the code block, then other threads can only have been waiting, waiting to acquire the lock thread releases the lock, the lock here and get the thread releases the lock only there are two issues:

1) to obtain the lock over this block of code execution thread, then the thread releases the possession of the lock;

2) abnormal thread execution has occurred and the JVM will automatically thread releases the lock

So if this thread to acquire the lock due to IO wait, or for other reasons (such as call sleep method) is blocked, but it does not release the lock, other threads will wait only dryly, Imagine how this affects performance efficiency.

So you need to have a mechanism to prevent the thread has been waiting indefinitely to wait any longer (for example, only wait for a certain time or be able to respond to the interrupt), you can do so by Lock.

Another example: When there are multiple threads to read and write files, read the phenomenon of conflict and write operations occur, write and write operations may conflict phenomenon, but read and read operations do not conflict occur.

But to achieve synchronization using the synchronized keyword, it would cause a problem:

If multiple threads are only read, so when a thread is performing a read operation, other threads can only wait can not be read.

Therefore we need a mechanism to enable multiple threads are only read, not conflict between threads, it can be done by Lock.

In addition, there is a thread Lock can know without success to obtain a lock. This can not be done is synchronized

14, cas operation

java.util.concurrent package achieved by means of a CAS different from the optimistic locking synchronized synchronization locks

cas is more and exchange algorithm

CAS has three operands, memory value V, the expected value of the old A, to be modified a new value B. If and only if the expected value of the A and V are the same memory value, the memory value V revised to B, otherwise do nothing

Providing AtomicReference JDK classes to guarantee atomicity references between objects, you can be put on an object in the plurality of variables to CAS operation.

15, the difference between the lock and synchronized?

(1) Lock is an interface, and the synchronized keyword in Java, synchronized built-in language;

(2) synchronized when an exception occurs, it will automatically release the thread owns the lock, it will not lead to a deadlock phenomenon; and Lock when an exception occurs, if there is no initiative by unLock () to release the lock, then it may cause a deadlock and, therefore, you need to release the lock in a finally block the use of lock;

(3) Lock lets wait for the lock thread in response to interrupts, but it's not synchronized, when using synchronized, waiting threads will wait forever, can not respond to interrupts;

(4) by Lock can know without success to obtain a lock, and synchronized it can not be done.

(5) Lock multiple threads can improve the efficiency of the read operation.

In terms of performance, if not fierce competition for resources, the performance of both is similar, but when the competition is very fierce resource (ie a large number of threads simultaneously competition), this time the performance is much better than Lock synchronized. So, to select appropriate in accordance with the specific use.

16, equity and non-equity lock lock

Fair and unfair lock queues are based on a doubly linked list lock internal maintenance, the value nodes Node tables each request is currently locked thread. Lock the fair that every time the value of the first order from the team

Unfair lock in the process of waiting for the lock, if there are any new threads attempt to acquire the lock, there is a great chance to get directly to the lock

(Obviously you can see in the ReentrantLock which includes two synchronous, are fair and unfair FairSync role of NonfairSync fair lock is in strict accordance with the order of thread starts to execute, do not allow other threads of execution to jump the queue; while unfair lock is allowed to jump the queue.

ReentrantLock is to synchronize, including the synchronized keyword is so unfair lock by default, because this performance will be better. Because RUNNABLE into the state from the thread, you can start to perform, the actual thread execution is to compare long time. Moreover, after the release of a lock, other threads will need to re-acquire the lock. Which experienced a thread releases the lock holding a lock, other threads RUNNABLE to recover from a hung state, other threads requesting a lock, get a lock, a thread of execution, this series of steps. If this time, there is a direct request thread lock might hang to avoid the consumption recovery RUNNABLE this state, it is more optimized performance)

17, read-write locks designed mainly to solve the problem?

Multithreading,

Read operations can be shared, the write operation is exclusive, reading can have multiple read, write only the only one in writing, the time allowed to read while write

To solve the reading and reading can be done simultaneously, can not read and write at the same time, write and write can not be performed at the same time

18, MySQL query page

LIMIT [offset,] rows

offset specifies the offset of the first row to be returned, rows of the second specified maximum number of rows returned

19, MySQL transaction isolation levels and characteristics

The basic elements of the transaction (ACID)

(1) atomicity (Atomicity): After the start of the transaction all operations, either all done, or all do not do, can not be stuck in the middle part. An error occurred during the execution of the transaction, will be rolled back to the state before the start of the transaction, all operations like never happened. That transaction is an indivisible whole, like a high school chemistry ever atom, is the basic unit of matter.

(2) Consistency (Consistency): the beginning and the end of the transaction, integrity constraints of the database is not corrupted before. For example, A transfers to B, A can not be deducted money, B did not receive.

(3) isolation (Isolation): the same time, only one transaction request for the same data, without any interference from each other between different transactions. For example, A is to withdraw money from a bank card, withdraw money before the end of the process A, B can not transfer money to the card.

(4) persistent (Durability): After the completion of the transaction, the transaction all updates to the database will be saved to the database can not be rolled back.

20, concurrency issues affairs

(1) Dirty read: Transaction A transaction B reads the data update and rollback B, then A read data is dirty data

(2) non-repeatable read: A transaction reads the same data multiple times, transaction transaction A times B in the course of the read, the data were updated and submitted. A read transaction resulting in the same data multiple times, the results are inconsistent .

(3) Magic Reading: A system administrator will result in the database specific scores for all students from grade ABCDE changed, but the system administrator B would insert a specific record score at this time, when the end of the A system administrator to change found that there is a record not change overnight, just like happened as hallucinations, this is called phantom reads.

21, use sql having scenes

If you need to set the result as a function of the conditions, you can not use the where clause, you must use the having clause

22, a front-end browser address http request to the backend of the whole process is how?

Can be said that under it?

DNS -> initiates a TCP three-way handshake -> http request to initiate the establishment of the TCP connection -> Server response http request, the browser get html code -> browser parses the html code and requests html code resources (such as js, css, images, etc.) -> browser page rendering presented to the user

23, http default port, https the default port

Common HTTP protocol proxy server port number: 80/8080/3128/8081/9080

HTTPS server, the default port number is 443 / tcp 443 / udp

24, DNS you know is doing it?

DNS means: the domain name server (Domain Name Server). On the Internet between domain names and IP address is one of the domain name though for people to remember, but only know each other between the machine IP address, the conversion work between them as domain name resolution, domain name resolution required by the specific domain name resolution server to complete, DNS is the domain name resolution server

Complete documentation for interview questions, selection of the latest recording and broadcasting, Java information, learning maps to provide free after years programmers want to quit or want a promotion and pay rise, plus micro-channel 13,272,413,561 Notes to free access to information Oh
2019 ants gold dress Java will ask interview questions (two faces)
2019 ants gold dress Java will ask interview questions (two faces)
2019 ants gold dress Java will ask interview questions (two faces)
2019 ants gold dress Java will ask interview questions (two faces)
2019 ants gold dress Java will ask interview questions (two faces)
2019 ants gold dress Java will ask interview questions (two faces)
acquisition mode:
HTTPS : //shimo.im/docs/TC9Jq63Tp6HvTXdg/

Guess you like

Origin blog.51cto.com/14587687/2466421