python face questions -1

1. Tcp protocol and udp protocols What is the difference?

  (1) TCP connection-oriented (e.g., dial-up connection is established first call); the UDP is connectionless, i.e. without establishing a connection before sending data.
  (2) each TCP connection can only point to point; UDP support one to one, one to many, and many-to-many interactive communication.
  (3) TCP header overhead of 20 bytes; small overhead UDP header, is only 8 bytes.
  (4) a logical communication channel is TCP reliable full-duplex channel, UDP is an unreliable channel.

  2. Post and get the difference?

  (1) GET request data will be exposed in the address bar, and POST request form submitted so post relatively safe there.
  (2) post is larger than the transmission data get.
  (3) post than get security.

  3. cookie and session difference?

  (1) cookie data is stored on the customer's browser, session data on the server.
  (2) cookie is not very safe, others can be analyzed at a local store COOKIE COOKIE cheat and should be used taking into account the security session.
  (3) session will be saved on the server for a certain time. When accessing the increase would be more occupy the server's performance taking into account mitigating server performance, you should use COOKIE.
  (4) a single cookie stored data can not exceed 4K, many browsers are limited to a maximum of 20 sites saved cookie.
  (5) Recommendation: The login information and other important information is stored as SESSION additional information if necessary, it can be placed in the COOKIE.

  4. What is a zombie process and orphaned, how to avoid the zombies?

  (1) orphan processes: the parent process exits, the child process child process is still running processes are orphans, orphans process will be will be adopted by other processes, will not be affected.
  (2) zombie process: the child process exits, the parent process and delay recovery, waste of resources.
  (3) Avoid zombies method: 1.fork twice with grandson process to complete the task child process. 2. Use wait () function allows the parent process blocked.

 

      5. scrapy and  scrapy-redis What is the difference?

  A: scrapy is a  Python framework reptile, crawling high efficiency, high degree of customization, but does not support distributed. The  scrapy-redis set based on  redis  database , run  the component on scrapy framework, allowing scrapy support distributed strategy, Slaver side shared  Master end  redis database of  item queue, the request queue and request a set of fingerprints.

 

    6. Description The following  mechanisms scrapy framework running?

  A: From the  acquired first in start_urls  url and a send request to the scheduler by the engine into the request queue, After completion of acquisition, the scheduler queue the request to the downloading request response corresponding to the request to acquire resources, and the analysis method in response to the extraction process to do their preparation: 1. If the extracted data is required to the document processing pipeline; 2. If the extracted url, then before continuing with step (transmission request url by engine the request to the scheduler queues ...), until the request queue is not requested, the program ends.

 

   7. Post and  get the difference and applications?

  the difference:

  Get: Gets data from the specified server. GET requests can be cached; GET requests will be saved in the History browser; with  a GET request URL can be saved as a browser bookmark; GET requests have length restrictions; GET request to obtain the main data.

  POST: POST request can not be cached; POST requests are not saved in the browser browsing history;  POST requested  URL could not be saved as a browser bookmark; POST request no length limit; POST request data request will be placed in the HTTP request packet package body , POST security than  the high of GET. You may modify resources on the server change request .

  Applications:

  post: result of the request have persistent side effects (add new rows of data in the database) The use of  data GET method, then collected on the form may make  URL too long. Data to be transmitted than using  7-bit  ASCII code.

  get: a request to find resources, HTML form data is only used to help search. Request results without side effects sustained. The data collected and  the total length of the input field names within the HTML form does not exceed  1024 characters.

 

   8. talk about  mysql  database storage principle?

  Storage process is a programmable function that created and saved in the database. It can have  SQL statements and some special control structures. When it is desired to perform the same function in different applications or internet, or a package with a particular function, the storage process is very useful. Database stored procedure can be seen as the programming object-oriented simulation process. It allows controlled access to data. Stored procedure typically has the following advantages:

  a, a stored procedure can achieve faster execution speed.

  b, stored programming procedure allows standard components.

  C, the storage process can be prepared by the process control statements, a lot of flexibility, and can perform complex judgment operation more complex.

  d, stored procedures can be used as a security mechanism to take advantage of.

  e, stored procedures can reduce network traffic.

 

  9. Database Index

  Database indexing, database management system, a sort of data structure to assist in rapid query, update data in a database table. Achieve an index commonly used  B_TREE. B_TREE indexes to speed up data access, because the storage engine does not go scan the entire table to get the data you need; rather, it starting from the root, root pointer to save the child node, the storage engine will quickly find the data according to the pointer.

 

  10. The database optimization program

  Index optimization, SQL statements, slow query analysis

  When designing a table in strict accordance with the design of the database paradigm to design the database

  Using the cache, the frequently accessed data and does not require frequent changes of data in the cache can save disk  IO

  Hardware optimization; using  SSD, using techniques disk queue (RAID0, RAID1, RDID5) and the like;

  Using MySQL own internal table partitioning technology, the different hierarchical data file can improve the efficiency of disk read

  Vertical table; some do not always read data in a table, save disk  I / O

  Separated from the main reader; master-slave copy the read and write operations are separated from the database

  Sub-library sub-table sub-machine (particularly large amount of data), the main principle is to route data

  Selecting the proper engine optimization parameter

  Make schema-level cache, static and distributed

  Do not use full-text index

  A faster storage, such as  data storage NoSql frequently accessed.

 

  11. how to optimize database query performance?

  1, the storage engine choices: If the data tables require a transaction, you should consider using  InnoDB, because it is in full compliance with  the ACID properties. If the transaction is not required, use the default storage engine  MyISAM is wiser

  2, sub-sub-table repository, from the master.

  3, query optimization, to try to avoid full table scans, you should first consider  where and  established by the order of the columns involved Index

  4, should be avoided in  the fields using the where clause  null value is determined, will cause the engine to give up using the index and a full table scan

  5, should be avoided in the  use where clause  ! = Or  <> operator, otherwise the engine to give up using the index and a full table scan

  6, should be avoided in the  where clause of the  connecting conditions or, if there is a field index, a field is not indexed, will cause the engine to give up using the index and a full table scan

  7, Update statements, if only to change the  1, 2 field, do not  Update all fields, otherwise called frequently cause significant performance overhead, and bring a lot of log

  8, for multiple large data volume (where hundreds even big) table  JOIN, first page again  JOIN, or logical reading will be high, poor performance.

Guess you like

Origin www.cnblogs.com/yblackd/p/12141786.html
Recommended