Note: Only part of the calculation will answer scores, not counting the scores supplementary question.
I will answer the first part
-
Description of OSI 7-layer model and its role? (2 minutes)
Physical layer data link layer network layer transport layer session layer denotes an application layer
-
Description of TCP three-way handshake, four recycling processes. (3 points)
establish connection
A syn initiated by the client request, the server receives and replies (ack syn)
After receiving the client and syn ack ack then return a confirmation
In the three-way handshake socket native code that is connect by accept
Disconnect the client sends a request to a service request to disconnect end server confirmation request to the client server initiates a disconnection request to the client the client to confirm disconnect request to the server
-
TCP and UDP difference? (3 points)
TCP protocol - a connection-oriented reliable transfer of infinite length full-duplex slow stream
UDP protocol - for unreliable connectionless datagram data transfer speed one-to-many many-length limited
-
What is a sticky bag? (2 minutes)
When multiple messages sent or accepted into a receiving inaccuracies occur
-
What B / S and C / S structure? (2 minutes)
Browser server just enter the URL you can use
Client Server
-
Implement a simple socket programming (client and server can send and receive messages) (3 min)
服务端 import socket sk = socket.socket() sk.bind(('127.0.0.1',8000)) sk.listen() conn,addr=sk.accept() mesg= conn.recv(1024).decode('utf-8') print(mesg) sonn.close() sk.close()
客户端 import socket sk = socket.socket() sk.connect(('127.0.0.1',8000)) mesg= sk.send('hello world'.encode('utf-8')) sk.close()
-
Description of processes, threads, coroutines difference? (3 points)
Can improve concurrency smallest unit of computer resource allocation process, the smallest unit of cpu thread scheduling can actually make a thread turns to perform some task coroutine can be called micro-threads, it is considered based on the code created by the process a thread is a computer and a real one thread can create multiple coroutines
-
What is GIL lock? (2 minutes)
Global Interpreter Lock
The same time ensure that only one thread in a process can be CPU scheduling
-
How to communicate between processes? (2 minutes)
IPC
-
How to use Python thread pool process pool? (2 minutes)
Thread Pool
from concurrent.futures import ThreadPoolExecutor
import time
def task(n1,n2):
time.sleep(2)
print('任务')
return 666
pool = ThreadPoolExecutor(10)
num = int(input(">>>"))
for i in range(num):
pool.submit(task,i,1)
pool.shutdown(True)
print('end')
ret = pool.map(task,range(1,20))
print('end',ret)
pool.shutdown(True)
for item in ret:
print(item)Process pool
from concurrent.futures import ProcessPoolExecutor
import time
def task(n1,n2):
time.sleep(2)
print('任务')
return 666
pool = ProcessPoolExecutor(10)
num = int(input(">>>"))
for i in range(num):
pool.submit(task,i,1) -
Implement a coroutine by the yield keyword? (2 minutes)
-
What is asynchronous non-blocking? (2 minutes)
Experience blocking does not wait for the program to continue
-
What is a deadlock? How to avoid? (2 minutes)
When two threads wait for each other to each other, a deadlock occurs to avoid multiple locking
Use time lock
It has the same order locking deadlock detection
-
Flag a program is executed from time to falg b roughly how many seconds? (2 minutes)
import threading
import time
def _wait():
time.sleep(60)
# flag a
t = threading.Thread(target=_wait)
t.setDeamon(False)
t.start()
# flag b 60 -
Flag a program is executed from time to falg b roughly how many seconds? (2 minutes)
import threading
import time
def _wait():
time.sleep(60)
# flag a
t = threading.Thread(target=_wait)
t.setDeamon(True)
t.start()
# flag b
0 -
Flag a program is executed from time to falg b roughly how many seconds? (2 minutes)
import threading
import time
def _wait():
time.sleep(60)
# flag a
t = threading.Thread(target=_wait)
t.start()
t.join()
# flag b
60 -
Read program, make sure to perform certain whether the last number is 0 (2 points)
import threading
loop = int(1E7)
def _add(loop:int = 1):
global number
for _ in range(loop):
number += 1
def _sub(loop:int = 1):
global number
for _ in range(loop):
number -= 1
number = 0
ta = threading.Thread(target=_add,args=(loop,))
ts = threading.Thread(target=_sub,args=(loop,))
ta.start()
ta.join()
ts.start()
ts.join()
0 -
Read program, make sure to perform certain whether the last number is 0 (2 points)
import threading
loop = int(1E7)
def _add(loop:int = 1):
global number
for _ in range(loop):
number += 1
def _sub(loop:int = 1):
global number
for _ in range(loop):
number -= 1
number = 0
ta = threading.Thread(target=_add,args=(loop,))
ts = threading.Thread(target=_sub,args=(loop,))
ta.start()
ts.start()
ta.join()
ts.join() -
MySQL database engine and Common difference? (3 points)
-
Description of the transaction and its characteristics? (3 points)
A plurality of transaction for some SQL operations as an atomic operation, once a certain error occurs, can roll back to the original state, to ensure data integrity database
Atomicity, consistency, isolation, durability
-
Transaction isolation level? (2 minutes)
Read uncommitted Read Committed Repeatable read serial
-
char and varchar difference? (2 minutes)
char type is a fixed-length space for time
varchar type is a variable length of time for space
-
Meaning the difference between the char and the mysql varchar and (50) represented in 50 varchar. (2 minutes)
50 char varchar maximum length of 50 characters
-
MySQL, delete and truncate difference of? (2 minutes)
delete delete delete all data in a data truncate
-
where clause has a, b, c three query, create a composite index abc (a, b, c), which of the following would hit the index (3 points)
(a)
(b)
(c)
(a,b)
(b,c)
(a,c)
(a,b,c) 1 -
What principles to follow composite index hit an index? (2 minutes)
High screening efficiency to create indexed columns
Small discrimination is not suitable for creating an index
Large range of small fast query slow
And a plurality of conditions connected by
-
MySQL listed common function? (3 points)
max min sum avg concat length date_format
-
MySQL database import, export command what? (2 minutes)
Export the entire database: mysqldump -u username -p password database name> dbname.sql;
Connected source sql file
Importing
mysql --default-character-set=utf8 -u root -p 名 <news.sql
-
What is SQL injection? (2 minutes)
Sql codes added to the input parameters, is transmitted to parse and execute sql server
-
Brief left join and inner join difference? (2 minutes)
Left inside connection
-
SQL statement having the role? (2 minutes)
Filter out qualified data
-
MySQL database varchar and text can store a maximum number of characters? (2 minutes)
65535
-
MySQL indexes There are several ways? (3 points)
-
-
Database optimization? (3 points)
-
What is MySQL slow logs? (2 minutes)
-
Design table, the relationship is as follows: teachers, classes, students and departments. (4 points) department and teacher-to-many relationship between the teacher and the class as many relationships, class and student-to-many relationship, to be reflected in the department hierarchy.
1. Write the respective tables of logical fields
according to the above table
a. Number query teacher student id = 1
b. Department query id = number of the lower sector 3 of
c. Queries brought up teacher student id -
There are staff tables, fields, primary key Sid, name Sname, Sex Sex (value of "male" or "female"), curriculum Course, field primary key Cid, course name Cname, table SC_Relation, field Student table's primary key Sid and course table's primary key Cid, form a joint primary key, please write all queries select "computer" course of a man's name with a SQL query. (3 points)
-
Write SQL statements based on relationships between tables (10 points)
-
All the students query number, name, number of elective total score;
-
Queries teacher surnamed "Li" of the number;
-
Discover an average score greater than 60 points and the number of students in the school grade point average;
-
Queries have less than 60 points of the course grade students of school, name
-
Delete learning "Ye Ping" teacher class score table records;
-
Query subjects highest score and lowest points: Displayed in the following form: Course ID, highest score, lowest score;
-
The number of queries for each course is elective students;
-
Check out only enrolled in a course all students learn numbers and names;
-
Students elective query "Yang Yan" teacher grant program, the highest-achieving students names and grades;
-
Query failed two or more courses of study and number of students grade point average;
-
The second part of the supplementary question
-
What is the IO multiplexing?
-
the role of async / await keywords?
-
MySQL implementation plan of action?
-
Description of MySQL triggers, functions, views, stored procedures?
-
There are tables in the database: t_tade_date
ID tade_date . 1 2018-1-2 2 2018-1-26 . 3 2018-2-8 . 4 2018-5-6 ... output on the last day of each month ID
-