linux内核tcp配置导致的web服务偶发无法访问
问题描述
一个web项目时有用户无法访问的情况,过一会又可以访问,这个问题困扰了很长一段时间,一直以为是DNS的问题。后来在看了一篇文章 “三次握手,四次挥手”https://www.cnblogs.com/qcrao-2018/p/10182185.html你真的懂吗? 看到关于 tcp的连接队列的时候,猛然意识到问题出在了哪, 遂连上服务器查看,果然linux的tcp配置有问题
一个web项目时有用户无法访问的情况,过一会又可以访问,这个问题困扰了很长一段时间,一直以为是DNS的问题。后来在看了一篇文章 “三次握手,四次挥手”https://www.cnblogs.com/qcrao-2018/p/10182185.html你真的懂吗? 看到关于 tcp的连接队列的时候,猛然意识到问题出在了哪, 遂连上服务器查看,果然linux的tcp配置有问题
# 显示授予用户的权限
SHOW GRANTS;
# 显示所有数据库
SHOW DATABASES;
# 使用指定数据库
USE `database_name`;
# 显示创建数据库的MySQL语句
SHOW CREATE DATABASE `database_name`;
# 显示所有表
SHOW TABLES;
# 显示表结构
DESC `table_name`;
# 查询所有字段
SELECT * FROM `table_name`;
# 指定查询字段
SELECT `field1_name`,`field2_name` FROM `table_name`;
# 排序
SELECT * FROM `table_name` ORDER BY `field_name`;
# 限制数量
SELECT * FROM `table_name` ORDER BY `field_name` LIMIT 1;
SELECT * FROM `table_name` WHERE id = 25;
# OR 操作符
SELECT * FROM `table_name` WHERE id = 25 or id = 35;
# AND 操作符
SELECT * FROM `table_name` WHERE (tall = 175 or tall = 180) and age >= 25;
# IN 操作符
SELECT * FROM `table_name` WHERE id IN (25, 35);
# NOT 操作符
SELECT * FROM `table_name` WHERE id NOT IN (25, 35);
# LIKE 操作符
SELECT * FROM `table_name` WHERE name LIKE '%James%';
# 标准库
from math import sqrt
from os.path import abspath
# Django导入
from django.db import models
from django.utils.translation import ugettext_lazy as _
# 第三方应用导入
from rest_framework.response import Response
# 导入自己的应用
from user.models import User
id
type
等Python关键字给变量命名# 神奇的数字
def func(state):
if state == 2:
return 5
if state == 3:
return 10
return 13
.pre-commit-config.yaml
yum install git
git clone https://github.com/python/cpython.git
cd cpython
git checkout v3.7.0
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
xz -d Python-3.7.0.tar.xz
tar xvf Python-3.7.0.tar
yum install gcc
yum install zlib zlib-devel
yum install libffi-devel
yum install sqlite-devel
yum install readline-devel
yum install openssl openssl-devel
yum install bzip2
yum install uuid-devel
yum install ncurses-devel
yum install gdbm-devel
yum install xz-devel
yum install tk-devel
./configure --help
./configure
make
make install
make clean
class TreeNode(object):
def __init__(self, val=None, left=None, right=None):
self.left = left
self.right = right
self.val = val
class BinTree(object):
def __init__(self, root):
self.root = root
def stack_print(self, root):
"""堆栈实现"""
stack = []
while root or stack:
while root:
stack.append(root)
print(root.val)
root = root.left
if stack:
root = stack.pop()
root = root.right
def recursive_print(self, root):
"""递归实现"""
if not root:
return
print(root.val)
self.recursive_print(root.left)
self.recursive_print(root.right)
def main():
left = TreeNode(2, left=TreeNode(4), right=TreeNode(5))
right = TreeNode(3, left=TreeNode(6), right=TreeNode(7))
root = TreeNode(1, left=left, right=right)
tree = BinTree(root)
print('递归 先序遍历:')
tree.recursive_print(tree.root)
print('堆栈 先序遍历:')
tree.stack_print(tree.root)
class TreeNode(object):
def __init__(self, val=None, left=None, right=None):
self.left = left
self.right = right
self.val = val
class BinTree(object):
def __init__(self, root):
self.root = root
def stack_print(self, root):
"""堆栈实现"""
stack = []
while root or stack:
while root:
stack.append(root)
root = root.left
if stack:
root = stack.pop()
print(root.val)
root = root.right
def recursive_print(self, root):
"""递归实现"""
if not root:
return
self.recursive_print(root.left)
print(root.val)
self.recursive_print(root.right)
def main():
left = TreeNode(2, left=TreeNode(4), right=TreeNode(5))
right = TreeNode(3, left=TreeNode(6), right=TreeNode(7))
root = TreeNode(1, left=left, right=right)
tree = BinTree(root)
print('递归 中序遍历:')
tree.recursive_print(tree.root)
print('堆栈 中序遍历:')
tree.stack_print(tree.root)
class TreeNode(object):
def __init__(self, val=None, left=None, right=None):
self.left = left
self.right = right
self.val = val
class BinTree(object):
def __init__(self, root):
self.root = root
def stack_print(self, root):
"""堆栈实现"""
if not root:
return
stack1 = []
stack2 = []
node = root
stack1.append(node)
while stack1:
node = stack1.pop()
if node.left:
stack1.append(node.left)
if node.right:
stack1.append(node.right)
stack2.append(node)
while stack2:
print(stack2.pop().val)
def recursive_print(self, root):
"""递归实现"""
if not root:
return
self.recursive_print(root.left)
self.recursive_print(root.right)
print(root.val)
def main():
left = TreeNode(2, left=TreeNode(4), right=TreeNode(5))
right = TreeNode(3, left=TreeNode(6), right=TreeNode(7))
root = TreeNode(1, left=left, right=right)
tree = BinTree(root)
print('递归 后序遍历:')
tree.recursive_print(tree.root)
print('堆栈 后序遍历:')
tree.stack_print(tree.root)
class TreeNode(object):
def __init__(self, val=None, left=None, right=None):
self.left = left
self.right = right
self.val = val
class BinTree(object):
def __init__(self, root):
self.root = root
def level_queue(self, root):
if not root:
return
storage = []
node = root
storage.append(node)
while storage:
node = storage.pop(0)
print(node.val)
if node.left:
storage.append(node.left)
if node.right:
storage.append(node.right)
def main():
left = TreeNode(2, left=TreeNode(4), right=TreeNode(5))
right = TreeNode(3, left=TreeNode(6), right=TreeNode(7))
root = TreeNode(1, left=left, right=right)
tree = BinTree(root)
print('队列 层次遍历:')
tree.level_queue(tree.root)