当前位置:首页>python>构建永不崩溃的可扩展 Python 系统

构建永不崩溃的可扩展 Python 系统

  • 2026-03-22 06:34:42
构建永不崩溃的可扩展 Python 系统
来源丨经授权转自 数据STUDIO
者丨云朵君

架构决定了系统的命运,远在你写下第一行路由代码之前

作为一名Python开发者,你是否也曾经历过这样的场景:

  • 用户量刚破万,系统就开始响应缓慢
  • 并发请求一上来,数据库连接池直接爆掉
  • 凌晨三点被报警叫醒,因为某个后台任务卡死了主进程

我曾经以为,“可扩展”就是“能跑在云服务器上”。直到我亲手构建(也亲手搞崩)了十几个Python后端系统后,才真正明白:真正的可扩展性不是加服务器,而是消除瓶颈

今天,我将与你分享这些年总结的Python高并发系统设计经验,从并发模型到负载均衡,再到优雅的故障恢复——让你少走弯路,直抵核心。

一、架构优先

为什么框架选择远不及架构设计重要?

很多开发者一上手就直奔Flask或FastAPI。但我想告诉你一个残酷的事实:在你写下第一个路由之前,架构就已经决定了系统的成败

我每个可扩展的Python系统都从模块化边界开始——每个服务只做好一件事。

# 可扩展Python项目的目录结构app/    __init__.py    api/              # API层        __init__.py        routes.py     # 路由定义    core/             # 核心模块        __init__.py        config.py     # 配置管理        database.py   # 数据库连接    services/         # 业务服务层        __init__.py        user_service.py    # 用户服务        email_service.py   # 邮件服务    utils/            # 工具函数        __init__.py        logging.py    # 日志配置

为什么这种结构如此重要?

  1. 服务隔离:邮件服务可以完全重写,而不影响用户服务
  2. 精准测试:每个模块都能独立测试
  3. 调试友好:问题定位像做外科手术一样精准

架构就像整理书架:一开始就分门别类,后续找书、放书都事半功倍。反之,如果一开始把所有书堆在一起,系统越大,维护成本越高。

二、异步编程

单进程处理上万并发的秘密武器

如果你的Python代码还在使用阻塞式I/O,那么你正在白白浪费性能。Python的asyncio生态,配合aiohttpFastAPI,可以在单进程中处理数万并发请求

import asyncioimport aiohttpfrom datetime import datetimeasyncdeffetch_page(session, url):"""异步获取单个页面"""asyncwith session.get(url) as response:        html = await response.text()return len(html)  # 返回页面长度asyncdefmain():"""主函数:并发获取100个页面"""    start_time = datetime.now()asyncwith aiohttp.ClientSession() as session:# 创建100个并发任务        tasks = [fetch_page(session, f"https://httpbin.org/delay/{i%3}"for i in range(100)]# 同时执行所有任务        results = await asyncio.gather(*tasks)    elapsed = (datetime.now() - start_time).total_seconds()    print(f"并发获取100个页面,总耗时: {elapsed:.2f}秒")    print(f"获取到的总字符数: {sum(results)}")# 运行异步程序if __name__ == "__main__":    asyncio.run(main())

输出示例

并发获取100个页面,总耗时: 3.42秒获取到的总字符数: 124500

性能对比:传统同步方式获取100个页面(每个延迟1-3秒)需要100+秒,而异步方式仅需3-4秒,性能提升30倍以上

三、负载均衡

当单进程不再够用时的应对策略

当你的FastAPI应用迎来第一波真实流量时,瓶颈往往不是代码逻辑,而是进程模型。

解决方案:Gunicorn + Uvicorn多工作进程

# 启动4个工作进程,每个进程都能处理并发请求gunicorn main:app \  --workers 4 \  --worker-class uvicorn.workers.UvicornWorker \  --bind 0.0.0.0:8000 \  --timeout 120 \  --keepalive 5

各参数含义

  • --workers 4:启动4个工作进程,充分利用多核CPU
  • --worker-class uvicorn.workers.UvicornWorker:使用Uvicorn的ASGI worker
  • --timeout 120:请求超时时间120秒
  • --keepalive 5:HTTP keep-alive连接

对于真正需要大规模扩展的系统,我建议的完整技术栈:

  1. 容器编排:Docker Swarm / Kubernetes
  2. 消息队列:Redis Streams / RabbitMQ
  3. 服务发现:Consul / etcd
  4. 监控告警:Prometheus + Grafana + Alertmanager

四、数据库扩展

别让数据库成为系统瓶颈

你的Python代码可以很完美,但如果数据库撑不住,整个系统照样崩盘。

我的核心技巧:连接池 + 读写分离

from sqlalchemy import create_enginefrom sqlalchemy.orm import sessionmakerfrom sqlalchemy.pool import QueuePoolfrom contextlib import contextmanagerimport redis# 主数据库(写操作)WRITE_ENGINE = create_engine("postgresql+psycopg2://user:password@master-host/db",    poolclass=QueuePool,    pool_size=20,           # 连接池中保持的连接数    max_overflow=10,        # 允许超过pool_size的连接数    pool_timeout=30,        # 获取连接的超时时间(秒)    pool_recycle=1800,      # 连接回收时间(秒)    echo=False# 是否打印SQL语句(生产环境设为False))# 只读副本(读操作)READ_ENGINE = create_engine("postgresql+psycopg2://user:password@replica-host/db",    pool_size=30,           # 读库通常需要更多连接    max_overflow=20)# Redis缓存redis_client = redis.Redis(    host='localhost',    port=6379,    db=0,    decode_responses=True# 自动解码返回的字节数据)# 会话工厂WriteSession = sessionmaker(bind=WRITE_ENGINE)ReadSession = sessionmaker(bind=READ_ENGINE)@contextmanagerdefget_write_session():"""获取写数据库会话(上下文管理器)"""    session = WriteSession()try:yield session        session.commit()except Exception as e:        session.rollback()raise efinally:        session.close()@contextmanagerdefget_read_session():"""获取读数据库会话(上下文管理器)"""    session = ReadSession()try:yield sessionfinally:        session.close()# 使用示例defget_user_with_cache(user_id: int):"""带缓存的用户查询"""# 1. 先查缓存    cache_key = f"user:{user_id}"    cached_data = redis_client.get(cache_key)if cached_data:        print(f"从缓存获取用户 {user_id}")return eval(cached_data)  # 实际项目请使用JSON解析# 2. 缓存未命中,查询数据库with get_read_session() as session:# 这里应该是实际的ORM查询# user = session.query(User).filter_by(id=user_id).first()        user_data = {"id": user_id, "name""张三""email""zhangsan@example.com"}# 3. 写入缓存(设置60秒过期)        redis_client.setex(cache_key, 60, str(user_data))        print(f"从数据库获取用户 {user_id},并写入缓存")return user_data

数据库扩展进阶方案

  1. 异步数据库驱动:使用asyncpg + databases
  2. 分库分表:当单表数据量超过千万时考虑
  3. 查询优化:合理使用索引,避免N+1查询问题

五、Celery分布式任务

让耗时操作不再阻塞主线程

如果后台任务阻塞了主请求线程,你的系统永远无法真正扩展。Celery是我处理异步分布式任务的首选工具。

# celery_tasks.pyfrom celery import Celeryimport timefrom datetime import datetime# 创建Celery应用,使用Redis作为消息代理app = Celery('tasks',    broker='redis://localhost:6379/0',  # 消息代理    backend='redis://localhost:6379/1'# 结果存储)# 配置Celeryapp.conf.update(    task_serializer='json',    accept_content=['json'],    result_serializer='json',    timezone='Asia/Shanghai',    enable_utc=True,    worker_max_tasks_per_child=1000,  # 每个worker最多执行1000个任务    broker_pool_limit=50# 连接池限制)@app.task(bind=True, max_retries=3)defsend_email(self, user_email, subject, content):"""发送邮件任务(模拟)"""try:        print(f"[{datetime.now()}] 开始发送邮件给 {user_email}")# 模拟耗时操作        time.sleep(2)# 模拟10%的失败率import randomif random.random() < 0.1:raise Exception("模拟邮件发送失败")        print(f"[{datetime.now()}] 邮件发送成功: {user_email}")return {"status""success""email": user_email}except Exception as exc:# 任务失败,重试(最多3次)        print(f"邮件发送失败,第{self.request.retries + 1}次重试")raise self.retry(exc=exc, countdown=2 ** self.request.retries)@app.taskdefgenerate_report(user_id, report_type):"""生成报表任务"""    print(f"开始为用户 {user_id} 生成 {report_type} 报表")    time.sleep(5)  # 模拟耗时操作return {"user_id": user_id,"report_type": report_type,"url"f"/reports/{user_id}/{report_type}.pdf"    }

启动Celery Worker

# 启动worker,并发数为4celery -A celery_tasks worker \  --loglevel=info \  --concurrency=4 \  --hostname=worker1@%h

在FastAPI应用中调用任务

# main.pyfrom fastapi import FastAPI, BackgroundTasksfrom celery_tasks import send_email, generate_reportimport asyncioapp = FastAPI()@app.post("/send-welcome-email")asyncdefsend_welcome_email(user_email: str, background_tasks: BackgroundTasks):"""发送欢迎邮件"""# 立即返回响应,邮件在后台发送    task = send_email.delay(        user_email=user_email,        subject="欢迎加入我们!",        content="感谢您注册我们的服务..."    )return {"message""邮件发送任务已提交","task_id": task.id,"status""processing"    }@app.get("/task-status/{task_id}")asyncdefget_task_status(task_id: str):"""查询任务状态"""from celery_tasks import app as celery_app    result = celery_app.AsyncResult(task_id)return {"task_id": task_id,"status": result.status,"result": result.result if result.ready() elseNone    }

六、缓存与限流

高并发系统的隐形守护者

每个我构建的可扩展应用都有两个隐形英雄:缓存限流

1. 智能缓存策略

from aiocache import cached, Cachefrom aiocache.serializers import PickleSerializerimport asyncio# 配置缓存Cache.REDIS_ENDPOINT = "localhost"Cache.REDIS_PORT = 6379@cached(    ttl=300,  # 缓存5分钟    cache=Cache.REDIS,    key="user_profile_{user_id}",    serializer=PickleSerializer())asyncdefget_user_profile(user_id: int):"""获取用户资料(带缓存)"""    print(f"查询数据库获取用户 {user_id} 的资料")# 模拟数据库查询await asyncio.sleep(1)return {"id": user_id,"name"f"用户{user_id}","email"f"user{user_id}@example.com","last_login""2024-01-15 10:30:00"    }asyncdefmain():# 第一次调用:访问数据库    user1 = await get_user_profile(1)    print(f"第一次查询: {user1['name']}")# 第二次调用:从缓存读取    user1_cached = await get_user_profile(1)    print(f"第二次查询(缓存): {user1_cached['name']}")asyncio.run(main())

2. 接口限流保护

from slowapi import Limiter, _rate_limit_exceeded_handlerfrom slowapi.util import get_remote_addressfrom slowapi.errors import RateLimitExceededfrom fastapi import FastAPI, Requestimport time# 初始化限流器limiter = Limiter(key_func=get_remote_address)app = FastAPI()app.state.limiter = limiterapp.add_exception_handler(RateLimitExceeded, _rate_limit_exceeded_handler)# 自定义内存限流(不依赖Redis的简单方案)classSimpleRateLimiter:def__init__(self, requests_per_minute: int = 60):        self.requests_per_minute = requests_per_minute        self.requests = {}  # ip: [timestamp1, timestamp2, ...]defis_allowed(self, ip: str) -> bool:        now = time.time()        minute_ago = now - 60if ip notin self.requests:            self.requests[ip] = []# 清理一分钟前的记录        self.requests[ip] = [t for t in self.requests[ip] if t > minute_ago]if len(self.requests[ip]) < self.requests_per_minute:            self.requests[ip].append(now)returnTruereturnFalse# 使用限流器rate_limiter = SimpleRateLimiter(requests_per_minute=30)@app.middleware("http")asyncdefrate_limit_middleware(request: Request, call_next):    client_ip = request.client.hostifnot rate_limiter.is_allowed(client_ip):return JSONResponse(            status_code=429,            content={"detail""请求过于频繁,请稍后再试"}        )    response = await call_next(request)return response@app.get("/api/data")@limiter.limit("10/minute")  # 使用slowapi的装饰器asyncdefget_data(request: Request):return {"data""这是受保护的数据"}

七、监控与可观测性

不给系统埋下定时炸弹

没有可观测性的系统就像闭眼开车。我推荐的技术栈:结构化日志(loguru)+ 指标收集(prometheus_client)+ 分布式追踪。

from loguru import loggerfrom prometheus_client import start_http_server, Counter, Histogramimport timefrom contextlib import contextmanager# 配置结构化日志logger.add("logs/app_{time:YYYY-MM-DD}.log",    rotation="1 day",    retention="30 days",    compression="zip",    format="{time:YYYY-MM-DD HH:mm:ss} | {level} | {message}",    level="INFO")# 定义指标REQUEST_COUNT = Counter('app_requests_total','应用总请求数',    ['method''endpoint''status'])REQUEST_DURATION = Histogram('app_request_duration_seconds','请求处理时间',    ['endpoint'])@contextmanagerdeftrack_request(method: str, endpoint: str):"""追踪请求的上下文管理器"""    start_time = time.time()try:yield        status = "200"except Exception as e:        status = "500"raise efinally:        duration = time.time() - start_time# 记录指标        REQUEST_COUNT.labels(method=method, endpoint=endpoint, status=status).inc()        REQUEST_DURATION.labels(endpoint=endpoint).observe(duration)# 记录日志        logger.info(f"{method}{endpoint} - Status: {status} - Duration: {duration:.3f}s"        )# 示例:在FastAPI中间件中使用@app.middleware("http")asyncdefmonitoring_middleware(request: Request, call_next):with track_request(request.method, request.url.path):        response = await call_next(request)return response# 启动Prometheus指标服务器(在另一个线程)defstart_metrics_server():    start_http_server(8000)  # 指标暴露在 http://localhost:8000/metrics    logger.info("Prometheus metrics server started on port 8000")# 在主程序中启动import threadingmetrics_thread = threading.Thread(target=start_metrics_server, daemon=True)metrics_thread.start()

八、优雅关闭与错误恢复

让系统学会"体面地离开"

在扩展系统时,你的应用必须知道如何优雅地关闭。

from fastapi import FastAPIfrom contextlib import asynccontextmanagerimport asynciofrom typing import Dictimport signalimport sys# 全局状态管理classAppState:def__init__(self):        self.is_shutting_down = False        self.active_connections: Dict[str, asyncio.Task] = {}defadd_connection(self, conn_id: str, task: asyncio.Task):        self.active_connections[conn_id] = taskdefremove_connection(self, conn_id: str):if conn_id in self.active_connections:del self.active_connections[conn_id]app_state = AppState()@asynccontextmanagerasyncdeflifespan(app: FastAPI):"""应用生命周期管理"""# 启动时    print("🚀 应用启动中...")# 注册信号处理器    loop = asyncio.get_running_loop()for sig in (signal.SIGTERM, signal.SIGINT):        loop.add_signal_handler(sig, lambda: shutdown_handler(app))yield# 应用运行期间# 关闭时    print("🛑 应用关闭中...")await graceful_shutdown()app = FastAPI(lifespan=lifespan)defshutdown_handler(app: FastAPI):"""处理关闭信号"""    print("收到关闭信号,开始优雅关闭...")    app_state.is_shutting_down = True# 取消所有活跃连接for conn_id, task in app_state.active_connections.items():ifnot task.done():            task.cancel()            print(f"取消连接: {conn_id}")asyncdefgraceful_shutdown():"""执行优雅关闭"""    print("关闭数据库连接...")# 这里关闭数据库连接池    print("停止后台任务...")# 这里停止Celery worker    print("刷新日志...")# 这里确保所有日志都写入磁盘    print("👋 应用已优雅关闭")

九、写在最后

可扩展性不只是技术问题,更是工程纪律问题。它体现在:

  1. 代码审查中坚持的架构原则
  2. 压测(使用locust)的常态化
  3. 文档的及时更新
  4. 知道何时重构的智慧

我常用的工具链:

  • 压测工具locust(模拟百万用户)
  • 性能基准pytest-benchmark(监控性能回归)
  • 代码格式化black + isort(统一代码风格)
  • 类型检查mypy(提前发现类型错误)

Python给了我们构建高并发系统的一切能力,关键在于我们如何明智地使用这些能力。

真正优秀的工程师,不是构建永不失败的系统,而是构建能够优雅失败的系统。

你在构建Python高并发系统时,还遇到过哪些挑战?或者有什么独特的解决方案?欢迎在评论区分享你的经验与思考!如果你觉得这篇文章有帮助,欢迎点赞、收藏、转发,让更多开发者少走弯路。

1、13 条 Claude Code 最佳实践,你在用了吗?

2、锁明明还没过期,为什么另一个线程能抢进去?

3、同样的功能,20行递归模板 vs 1行折叠表达式 —— C++17到底香在哪

4、面试官:只会 Redis?高并发下你的缓存架构怎么设计到极致?

5、2026 开发者必备:9 款终端 GPU 加速神器,效率直接拉满~

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-03-27 13:22:44 HTTP/2.0 GET : https://f.mffb.com.cn/a/479980.html
  2. 运行时间 : 0.101175s [ 吞吐率:9.88req/s ] 内存消耗:5,225.09kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=e0b0fffc31810efbb0a4c0fccee3c86e
  1. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/public/index.php ( 0.79 KB )
  2. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/autoload.php ( 0.17 KB )
  3. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/platform_check.php ( 0.90 KB )
  5. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_static.php ( 4.90 KB )
  7. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  10. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  11. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  12. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  13. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  14. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  15. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  16. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  17. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  18. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  19. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  20. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  21. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  22. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/provider.php ( 0.19 KB )
  23. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  24. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  25. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  26. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/common.php ( 0.03 KB )
  27. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  28. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  29. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/app.php ( 0.95 KB )
  30. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cache.php ( 0.78 KB )
  31. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/console.php ( 0.23 KB )
  32. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cookie.php ( 0.56 KB )
  33. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/database.php ( 2.48 KB )
  34. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  35. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/filesystem.php ( 0.61 KB )
  36. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/lang.php ( 0.91 KB )
  37. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/log.php ( 1.35 KB )
  38. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/middleware.php ( 0.19 KB )
  39. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/route.php ( 1.89 KB )
  40. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/session.php ( 0.57 KB )
  41. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/trace.php ( 0.34 KB )
  42. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/view.php ( 0.82 KB )
  43. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/event.php ( 0.25 KB )
  44. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  45. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/service.php ( 0.13 KB )
  46. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/AppService.php ( 0.26 KB )
  47. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  48. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  49. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  50. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  51. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  52. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/services.php ( 0.14 KB )
  53. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  54. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  55. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  56. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  57. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  58. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  59. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  60. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  61. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  62. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  63. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  64. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  65. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  66. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  67. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  68. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  69. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  70. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  71. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  72. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  73. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  74. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  75. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  76. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  77. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  78. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  79. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  80. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  81. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  82. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  83. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/Request.php ( 0.09 KB )
  84. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  85. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/middleware.php ( 0.25 KB )
  86. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  87. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  88. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  89. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  90. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  91. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  92. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  93. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  94. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  95. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  96. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  97. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  98. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  99. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/route/app.php ( 1.72 KB )
  100. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  101. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  102. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  103. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/controller/Index.php ( 4.81 KB )
  104. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/BaseController.php ( 2.05 KB )
  105. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  106. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  107. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  108. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  109. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  110. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  111. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  112. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  113. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  114. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  115. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  116. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  117. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  118. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  119. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  120. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  121. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  122. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  123. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  124. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  125. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  126. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  127. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  128. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  129. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  130. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  131. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  132. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  133. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  134. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  135. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  136. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  137. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  138. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  139. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/runtime/temp/067d451b9a0c665040f3f1bdd3293d68.php ( 11.98 KB )
  140. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.000580s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000622s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000292s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000291s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000467s ]
  6. SELECT * FROM `set` [ RunTime:0.000186s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000559s ]
  8. SELECT * FROM `article` WHERE `id` = 479980 LIMIT 1 [ RunTime:0.004516s ]
  9. UPDATE `article` SET `lasttime` = 1774588964 WHERE `id` = 479980 [ RunTime:0.005169s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.001249s ]
  11. SELECT * FROM `article` WHERE `id` < 479980 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.000500s ]
  12. SELECT * FROM `article` WHERE `id` > 479980 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.000702s ]
  13. SELECT * FROM `article` WHERE `id` < 479980 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.001799s ]
  14. SELECT * FROM `article` WHERE `id` < 479980 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.015463s ]
  15. SELECT * FROM `article` WHERE `id` < 479980 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.001189s ]
0.102963s