问题
需要服务端生成报表,由于数据量过大。往往会导致下载过程中504错误。
下载流程已经最优化了。
目前解决方案
前台点击下载报表,发起一个异步请求。后台处理完数据以后。把数据通过邮箱的方式发给下载者。
有没有其它更加好的办法,可以解决这个问题?谢谢。
回复内容:
问题
需要服务端生成报表,由于数据量过大。往往会导致下载过程中504错误。
下载流程已经最优化了。
目前解决方案
前台点击下载报表,发起一个异步请求。后台处理完数据以后。把数据通过邮箱的方式发给下载者。
有没有其它更加好的办法,可以解决这个问题?谢谢。
谢谢各位的回答。
这边我自己总结了一下,根据我自己的实际情况主要
- 前台异步提交一个请求,后台进行异步组合报表。然后通过1. 邮件的方式通知用户2. 通过定时器将消息PUSH给用户,让用户去相应的地址上下载
- 查询时间精确到秒。在用户请求之前,先告诉用户在这个时间段订单个数。我们可以设定一个合理的值来提示用户(改动最小)
- 采取任务的形式,前台提交一个任务给后台,后台创建一个任务,并且存入数据库。前台可以每隔30s向后台请求,获取任务的状态,以防止超时。相应的前台有一个loading框(这里也可以改成将文件的生成过程放在服务端,然后这里给用户返回的是一个连接,用户可以直接点连接来下载文件)(这个类似使用AJAX的长连接模式)
- 把分析过程放在服务端。服务端起一个定时任务,隔段时间去分析这些数据。直接生产文件放在服务端。可以提供给用户一个下载列表直接提供给用户下载
5.优化流程,采取dubbo批量数据请求。采取dubbo异步请求。多线程处理数据。多个dubbo服务合并(性能优化)
最直接的办法便是,压缩数据(例如导出时进行压缩),调整 CGI 超时时间。这其中,可以考虑节省 CGI 进程(因为即使输出成果已经完成,按照题主的说明,fast_cgi 的 response buffer 肯定是远远小于这次输出的大小),在最后输出的过程上用其他服务(例如直接用nginx)代劳。
其实,例如在问题中的这种从产品设计的角度解决问题在我看来最优解,实时下载真的是那么必要吗?
需要服务端生成报表,由于数据量过大。往往会导致下载过程中504错误。
看你的意思,超时的原因不是产生报表耗时太久,而是因为报表文件过大造成的。
3种做法
1.压缩报表文件,例如:tar,gzip,zip……
2.修改web服务器的超时时间设定。
3.导出的文件放到另外一个目录用其他工具下载,例如:ftp,samba,sftp……
边读数据,边写数据,比如分页读写,这样就不会超时了
换个思路,你的所有问题都在超时上面! 为什么超时,因为等待时间过长。那为什么要等待呢???
你可以发出请求,服务器端执行,告诉用户,正在执行,表示就成功了。然后就是用户接受邮件的等待。
这个时候,你可以告诉用户需要等待,或者加一个消息通知,成功后通知用户

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python are both high-level programming languages that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools