Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the test questions that Python engineers often meet?

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "what are the test questions that Python engineers often meet?" in the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

What is the difference between 1.Tcp and udp?

(1) TCP is connection-oriented (for example, dial-up to establish a connection); UDP is connectionless, that is, there is no need to establish a connection before sending data.

(2) each TCP connection can only be point-to-point; UDP supports one-to-one, one-to-many, many-to-one and many-to-many interactive communication.

(3) the overhead of the first part of TCP is 20 bytes, while that of UDP is only 8 bytes.

(4) the logical communication channel of TCP is a full-duplex reliable channel, while UDP is an unreliable channel.

The difference between 2.Post and get?

(1) the data requested by GET is exposed in the address bar, while the POST request is submitted in the form, so post is relatively secure.

(2) the data transmitted by post is larger than that of get.

(3) post is safer than get.

The difference between 3.cookie and session?

(1) the cookie data is stored on the client's browser and the session data is placed on the server.

(2) cookie is not very secure. Others can analyze the COOKIE stored locally and cheat on COOKIE to consider that session should be used for security.

(3) session will be saved on the server for a certain period of time. When access increases, it will take up the performance of the server. In order to reduce server performance, you should use COOKIE.

(4) the data stored in a single cookie cannot exceed 4K, and many browsers limit a site to save up to 20 cookie.

(5) suggestion: store important information such as login information as SESSION and other information if you need to keep it, you can put it in COOKIE.

4. What are zombie processes and orphan processes, and how to avoid zombie processes?

(1) Orphan process: these child processes that the parent process exits and the child process is still running are orphan processes, and the orphan process will be adopted by other processes without impact.

(2) Zombie process: the child process exits, but the parent process does not reclaim for a long time, resulting in a waste of resources.

(3) ways to avoid zombie processes: 1.fork uses grandchild processes twice to complete the tasks of child processes. two。 Use the wait () function to block the parent process.

What's the difference between 5.scrapy and scrapy-redis?

A: scrapy is a Python crawler framework that is highly efficient and highly customized, but does not support distribution. Scrapy-redis, a set of components based on redis database and running on scrapy framework, enables scrapy to support distributed strategy, and the Slaver side shares the collection of item queues, request queues and request fingerprints in the redis database on Master side.

6. Describe how the scrapy framework works?

Answer: get the first batch of url from start_urls and send the request. The request is sent to the scheduler by the engine to enter the request queue. After the request is obtained, the scheduler delivers the request in the request queue to the downloader to obtain the corresponding response resources, and gives the response to the parsing method written by itself for extraction: 1. If the required data is extracted, it will be handed over to the pipeline file for processing; 2. If the url is extracted, continue with the previous steps (sending the url request, and the engine sends the request to the scheduler for queuing...) until there is no request in the request queue and the program ends.

What is the difference and application between 7.Post and get?

Difference:

Get: gets data from the specified server. GET requests can be cached; GET requests can be saved in the browser's browsing record; URL with GET requests can be saved as browser bookmarks; GET requests are limited in length; GET requests are mainly used to obtain data.

The Post:POST request cannot be cached; the POST request will not be saved in the browser browsing record; the URL of the POST request cannot be saved as a browser bookmark; the POST request has no length limit; the POST request will place the requested data in the packet body of the HTTP request packet, and the security of POST is higher than that of GET. It is possible to modify the request to change the resource on the server.

Application situation:

Post: the result of the request has a persistent side effect (adding new rows of data in the database) if the GET method is used, the data collected on the form may make the URL too long. The data to be transmitted is not 7-bit ASCII encoding.

Get: the request is to find resources, and the HTML form data is only used to help with the search. The result of the request has no persistent side effects. The total length of the collected data and input field names in the HTML form does not exceed 1024 characters.

8. Talk about the principle of mysql database storage?

The storage process is a programmable function that is created and saved in the database. It can consist of SQL statements and some special control structures. Stored procedures are useful when you want to execute the same function on different applications or platforms, or to encapsulate specific functions. The stored procedure in the database can be regarded as a simulation of the object-oriented method in programming. It allows you to control how data is accessed. Stored procedures typically have the following advantages:

A, stored procedures can achieve faster execution speed.

B. stored procedures allow standard components to be programming.

C. The stored procedure can be written with flow control statements, which has strong flexibility and can complete complex judgments and more complex operations.

D. Stored procedures can be fully utilized as a security mechanism.

E. Stored procedures can reduce network traffic.

9. Database index

Database index is a sorted data structure in database management system to help quickly query and update data in database tables. The implementation of the index usually uses B_TREE. The B_TREE index accelerates data access because the storage engine no longer scans the entire table for the desired data; instead, it starts from the root node, which holds the pointers of the child nodes, and the storage engine quickly looks for data based on the pointers.

10. Database optimization scheme

Optimize indexes, SQL statements, and analyze slow queries

When designing tables, the database is designed strictly according to the design paradigm of the database.

Using caching, putting frequently accessed data and data that does not need to change frequently in the cache can save disk IO.

Optimize hardware, adopt SSD, use disk queue technology (RAID0,RAID1,RDID5), etc.

The use of MySQL internal table partitioning technology to layer data into different files can improve the reading efficiency of the disk.

Divide the table vertically; put some infrequently read data in a table to save disk Imax O

Master-slave read and write separation; master-slave replication is used to separate database read and write operations

Sub-library sub-table sub-machine (a large amount of data), the main principle is data routing

Select the appropriate table engine and optimize the parameters

Architecture-level caching, static, and distributed

Do not use full-text index

Adopt faster storage methods, such as NoSql to store frequently accessed data.

11. How does the database optimize query efficiency?

1. Storage engine selection: if the data table requires transaction processing, you should consider using InnoDB, because it fully conforms to the ACID feature. If transaction processing is not required, it is wise to use the default storage engine MyISAM

2. Sub-table and sub-library, master and slave.

3. To optimize the query and avoid full table scanning as far as possible, we should first consider establishing indexes on the columns involved in where and order by.

4. Try to avoid judging the null value of the field in the where clause, otherwise it will cause the engine to give up using the index and do a full table scan.

5. Try to avoid using the! = or operator in the where clause, otherwise the engine will give up using the index and do a full table scan

6. Try to avoid using or to join conditions in the where clause. If a field has an index and a field does not have an index, it will cause the engine to give up using the index and do a full table scan.

7. Update statement, if you change only 1 or 2 fields, do not Update all fields, otherwise frequent calls will cause obvious performance consumption and bring a large number of logs at the same time

8. For multiple tables with a large amount of data (a few hundred are considered large here), JOIN should be paged first and then JOIN, otherwise the logical reading will be very high and the performance will be very poor.

This is the end of the content of "what are the test questions that Python engineers often meet?" Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report