315 interview questions (2)

Source: Internet
Author: User
Tags epoll what is nginx

1. OSI Layer-7 protocol.
1. Physical Layer
Provides physical connections to the data link layer for transparent transmission of bit streams. The unit of transmitted data is bit, this layer defines the electrical, mechanical, and functional and process features of communication equipment and transmission line interface hardware.
2. Data Link Layer
Establish a data link connection between communication entities, transmit frame-based data, and check and recover bits that occur on the transfer link between the communication systems, make sure that the bits are composed of systems where data streams are transmitted to each other accurately. The data link layer implements transparent and high-reliability transmission between adjacent nodes.
3. Network Layer
Routing selection, congestion control, and network interconnection during multi-node transmission are implemented to control the operations of the group transmission system. Its features are transparent to the high-level management, select service quality as required by the transport layer and report unrecoverable errors to the transport layer.
4. Transport Layer
Establishes a transmission connection between the two terminal systems (the source station and the target station) to transmit packets reliably and transparently, the error control, sequence and traffic control, and management multiplexing at one end of the execution end. This layer provides the ability to establish, maintain, and remove transfer connections, and ensures the quality of network connections. It shields the details of lower-layer data communication from the high-level layer and thus is the most needed layer in the OSI network reference model.
5. Session Layer
It does not participate in specific data transmission, but manages the synchronization of data transmission. It is mainly responsible for establishing, maintaining, and Ending Session connections between two processes, and managing the necessary information transmission methods, synchronization between processes, and re-synchronization in processes.
6. Presentation Layer
This solution converts the encoding formats, syntax selection, data encryption and decryption, and text compression when information is exchanged between two communication systems.
7. Application Layer
Provides users with various network application services, such as file transmission, email, and remote access. Put the communication part of the process in the peer process into the application entity, and manage the communication functions of various business content.

2. What are the C/S and B/S architectures?
The C/S architecture software (that is, the Client/Server mode) is divided into two layers: client and server. The first layer is the combination of representation and business logic on the client system, the second layer combines the database server with the network. Simply put, the first layer is the user presentation layer, and the second layer is the database layer. The client and server are directly connected, and both components assume important roles.
B/S mode, that is, the Browser/Server structure. It is an improvement of the C/S architecture. It can be said that it belongs to a three-layer C/S architecture. It mainly utilizes the mature WWW browser technology and uses a general browser to implement the powerful functions that originally required complex specialized software, saving development costs, is a brand new software system construction technology.

3. Briefly describe the three-way handshake and four-way handshake.
The so-called three-way handshake (three-way handshake) is to establish a TCP connection, the client and the server need to send a total of three packets to confirm the establishment of the connection. In socket programming, the client executes connect to trigger this process.
1. First handshake:
The client sets the flag SYN to 1, generates a random value seq = J, and sends the packet to the server. The client enters the syn_sent status and waits for confirmation from the server.
1. second handshake:
After the server receives the data packet, the flag SYN = 1 knows the client request to establish a connection. The server sets both the flag SYN and ACK to 1, ACK = J + 1, generates a random value seq = K and sends the packet to the client to confirm the connection request. The server enters the syn_rcvd state.
1. Third handshake:
After receiving the confirmation, the client checks whether the Ack is J + 1 and the Ack is 1. If yes, it sets the flag ack to 1, ACK = k + 1, the server checks whether Ack is k + 1 and Ack is 1. If yes, the connection is established successfully. The client and server enter the established status and complete three handshakes, then the client and server can start to transmit data.

The so-called four waves (four-way wavehand) Terminate the TCP connection, that is, to disconnect a TCP connection, the client and the server need to send a total of four packets to confirm the disconnection. In socket programming, this process is triggered by the client or the server side executing the close operation.

The first wave:
The client sends a fin to disable data transmission from the client to the server. The client enters the fin_wait_1 status.
Second wave:
After the server receives the fin, it sends an ACK to the client and confirms that the serial number is the received serial number + 1 (same as SYN, one fin occupies one serial number). The server enters the close_wait status.
The third wave:
Server sends a fin to disable data transmission from the server to the client. The server enters the last_ack status.
The fourth wave:
After the client receives the fin, the client enters the time_wait status, and then sends an ACK to the server, confirming that the serial number is received by the serial number + 1. The server enters the closed status and completes four waves.
4. What is ARP?
Address Resolution Protocol (ARP) is a TCP/IP protocol for obtaining physical addresses based on IP addresses.

5. What is the difference between TCP and UDP?
Connection-based and connectionless
TCP requires a large amount of system resources and a small amount of UDP;
Simple UDP program structure
Stream mode (TCP) and datagram mode (UDP );
TCP ensures data correctness and UDP may cause packet loss.
TCP ensures data order, But UDP does not
6. What are LAN and WAN?
LAN and WAN are two computer networks based on their sizes. A computer network within several thousand meters is collectively referred to as a LAN. A computer network with over 10 km connections is called a Wan, and the Internet (intenet) is currently the largest Wan.

7. Why is TCP-based communication more reliable than UDP-based communication?
TCP's reliability guarantee is its three-way handshake mechanism, which ensures data validation and reliability. UDP does not exist. After UDP information is sent, It is unreliable because it does not verify whether the UDP information has arrived at the other party.

8. What is socket? Describes the TCP-based socket communication process.
Socket is an intermediate software abstraction layer for communications between the application layer and the TCP/IP protocol family. It is a group of interfaces. In the design mode, socket is actually a facade mode, which hides the complex TCP/IP protocol family behind the socket interface. for users, a set of simple interfaces are all, let the socket organize the data to conform to the specified protocol.

9. What is a stick package? What are the causes of package sticking in socket? In what situations will the package become stuck?
The packet data sent by the sender is pasted into a package when it is received by the receiver. In the receiving buffer zone, the header of the next packet is followed by the end of the previous packet. There are many reasons for the phenomenon of sticking packets, which may be caused by both the sender and the receiver.

The adhesive packet caused by the sender is caused by the TCP protocol itself. To improve transmission efficiency, the sender often needs to collect enough data before sending a packet of data. If few data is sent several times in a row, TCP will merge the data into a packet based on the optimization algorithm and send the data once. In this way, the receiver receives the data in the sticky packet.

The user process of the receiver fails to receive data in time, leading to the packet sticking phenomenon. This is because the receiver puts the received data in the system receiving buffer, and the user process obtains data from the buffer. If the data of the previous packet has not been taken away by the user process when the next packet arrives, then, when the next packet of data is placed in the system's receiving buffer zone, it is received after the previous packet of data, and the user process obtains data from the system's receiving buffer zone according to the preset buffer size, in this way, multiple packets of data are obtained at a time. Subcontracting refers to the process of subcontracting to our receiver when a stick package occurs.

10. What is the role of Io multiplexing?
I/O multiplexing uses a mechanism to monitor multiple descriptors. Once a descriptor is ready (generally read or write), it can notify the program to perform corresponding read/write operations.

11. What is a firewall and its role?
To put it simply, firewall is a protection tool that prevents hacker intrusion on your computer and a way to ensure network security!
Allows the network administrator to define a central point to prevent unauthorized users from accessing the internal network. 2. You can easily monitor network security and give an alarm. 3. it can be used as a location for deploying NAT (Network Address Translation). Using NAT technology, the limited IP addresses can be dynamically or statically mapped to internal IP addresses, used to alleviate address space shortage

12. What are the differences between select, poll, and epoll models?
(1) The select and poll implementations need to constantly poll all FD sets until the device is ready, during which sleep and wakeup may alternate multiple times. Epoll also needs to call epoll_wait to continuously poll the ready linked list. During this period, sleep and wake up may alternate multiple times. However, when the device is ready, epoll calls the callback function, put the ready FD in the ready linked list and wake up the sleep process in epoll_wait. Although both need to sleep and alternate, the Select and Poll must traverse the entire FD set while being "Awake, when epoll is "Awake", you only need to judge whether the ready linked list is empty, which saves a lot of CPU time. This is the performance improvement brought about by the callback mechanism.

(2) For select and poll, the FD set must be copied once from the user State to the kernel state, and the current must be mounted once to the device waiting queue, while epoll only needs to be copied once, in addition, the current is only mounted to the waiting queue once (at the beginning of epoll_wait, note that the waiting queue here is not a device waiting queue, but a waiting queue defined in epoll ). This can also save a lot of expenses.

13. Briefly describe the differences between processes, threads, and coroutine, And what application scenarios?
The process has its own heap and stack. Neither the heap nor the stack is shared. The process is scheduled by the operating system.

The thread has its own heap and shared stack share stack, but the non-shared heap thread is also scheduled by the operating system.

The coroutine has its own heap and shared stack share stack, but does not share the heap coroutine, which is called by the developer as appropriate.

14. What is the Gil lock?
GIL: Global interpreter lock. When we use multiple threads, each process has only one Gil lock. Then, whoever gets the Gil lock among these threads can use the CPU (PS: multiple processes have multiple Gil locks, but each process has only one Gil)

15. How to Use the thread pool and process pool in Python?
Process pool: Use multiprocessing. Pool
Thread Pool: Use threadpool Module

16. What is the role of threading. Local?
Threadlocal solves the problem of parameter passing between functions in a thread.
Although a threadlocal variable is a global variable, each thread can only read and write independent copies of its own thread.

17. How do processes communicate with each other?
Create a queue or use from multiprocessing import manage to manage the data to communicate

18. What is concurrency and parallelism?
Literal understanding

Parallel: Like a hundred-meter race, when a gunshot occurs, the athletes rush together, just like a program. This process is parallel.

Concurrency: Two or more events occur at the same interval.

19. What are the functions of process locks and thread locks?
When a multi-process or multi-thread does not need to access the same variable, it will cause the same thing to be executed at the same time without correct results. Therefore, you need to lock the global variable with a lock, other processes or threads cannot access a process or thread.

20. What is asynchronous non-blocking?
The asynchronous parties do not need a common clock, that is, the receiver does not know when the sender will send the message, so there must be a message prompting the receiver to start receiving the information, such as the start bit, at the same time, there is a stop position at the end.
The non-blocking mode refers to the use of the socket event message mechanism. Communication between the server and the client is asynchronous.

21. What is the difference between a vro and a vswitch?
A vro forwards information through an IP address. A vswitch forwards data to the next vro.

22. What is domain name resolution?
Domain name resolution is a service that directs domain names to the IP address of the website space so that people can conveniently access the website through registered domain names.

23. How do I modify the local hosts file?
In notepad, open the hosts file under c: \ windows \ system32 \ drivers \ etc and modify it.

24. What are the application scenarios and advantages of the producer and consumer model?
It is applicable to one scenario of producing data and processing data.
The advantage producers and consumers do not directly communicate with each other. Instead, a queue is equivalent to a buffer zone, balancing the processing capabilities of producers and consumers.

25. What is CDN?
Try to avoid bottlenecks and links on the Internet that may affect data transmission speed and stability, so that content transmission is faster and more stable. A layer of smart virtual network formed by placing node servers in various parts of the network on the basis of the existing Internet, the CDN system can redirect users' requests to the nearest service node in real time based on the network traffic and connection, load status, distance to the user and response time of each node..

26. What is LVS and its role?
Pass

27. What is nginx and its role?
We can understand that nginx is an HTTP server. HTTP servers with the same effect include Apache and tomcat.
Purpose:
1. HTTP server. Nginx is an HTTP service that provides HTTP services independently. Web static servers can be used.
2. VM. Multiple websites can be virtualized on one server. For example, the virtual host used by a personal website. Port-based, different ports based on domain names, different domain names
3. reverse proxy and Server Load balancer. When a website's access volume reaches a certain level and a single server cannot meet users' requests, you need to use multiple Server clusters to use nginx for reverse proxy. In addition, multiple servers can carry the load evenly, so that a server is not idle due to the high load of a server.

28. What is keepalived and its role?
Pass

29. What is haproxy and its role?
Pass

30. What is Server Load balancer?
Server Load balancer is a key component of the high-availability network infrastructure. With Server Load balancer, we can usually deploy multiple application servers, then, Server Load balancer distributes user requests to different servers to improve the performance and reliability of websites, applications, databases, and other services.

31. What are RPC and application scenarios?
Pass

32. Briefly describe the role and application scenarios of the asynio module.
Asyncio is a standard library introduced in Python 3.4 and has built-in support for asynchronous Io.
The Programming Model of asyncio is a message loop. We directly obtain an eventloop reference from the asyncio module, and then throw the coroutine to be executed into eventloop for execution, so that asynchronous Io is realized.

33. Briefly describe the functions and application scenarios of the gevent module.
When a greenlet encounters an I/O operation, such as accessing the network, it will automatically switch to another greenlet. After the I/O operation is completed, it will switch back to continue execution when appropriate. Since Io operations are very time-consuming, the program is often waiting. With gevent, We can automatically switch the coroutine to ensure that greenlet is always running, rather than waiting for Io.
Because the switchover is automatically completed during I/O operations, gevent needs to modify some standard libraries that come with python. This process is completed through Monkey patch at startup:

34. Use and Application of the twisted framework?
Twisted is an event-driven network engine framework implemented in Python. Twisted supports many common transport and application layer protocols, including TCP, UDP, SSL/TLS, HTTP, IMAP, ssh, IRC, and FTP. Just like python, twisted also features batteries-batterded. Twisted provides client and server implementation for all protocols it supports, along with command line-based tools, making it very convenient to configure and deploy product-level twisted applications.

315 interview questions (2)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.