我们正在使用 CppCMS 服务器,当发布消息达到一定大小的一些 kB 时,它的发布请求性能非常低。这已经发生在初学者教程的最小服务器示例中,稍作修改:
#include <cppcms/application.h>
#include <cppcms/applications_pool.h>
#include <cppcms/service.h>
#include <cppcms/http_request.h>
#include <cppcms/http_response.h>
#include <cppcms/mount_point.h>
#include <booster/intrusive_ptr.h>
#include <utility>
#include <iostream>
#include <boost/timer.hpp>
class hello
: public cppcms::application
{
public:
hello(cppcms::service &srv) :
cppcms::application(srv), counter(0) {}
virtual void main(std::string url);
boost::timer my_timer;
int counter;
};
void hello::main(std::string url)
{
response().out() << "Hello from asynchron CppCMS after " << my_timer.elapsed() << "s\n";
std::cout << "[" << url.size() << "] = " << url.substr(0, 50) << '\n';
}
int main(int argc,char ** argv)
{
try {
cppcms::service srv(argc,argv);
booster::intrusive_ptr<hello> p= new hello(srv);
srv.applications_pool().mount( p, cppcms::mount_point("(.*)") );
srv.run();
}
catch(std::exception const &e) {
std::cerr << e.what() << std::endl;
}
return 0;
}
奇怪的是,服务器在主函数中只花费了几毫秒,但两次调用之间只有一两秒。
- 这段时间CppCMS在做什么?
- 更重要的是,这个时间怎么能缩短?
- 是线程池的问题吗?
- 是否对帖子消息进行了一些昂贵的处理?(我读过一些关于压缩的东西)可以关闭或加速吗?
9 个带有 8 到 10kB 之间的 XML 文件的 post 请求需要 9 秒,甚至不需要处理这些请求。使用 node.js 服务器执行相同的请求不到半秒。我尝试了不同的配置并阅读了很多 dox 和帖子,但找不到可以解释这些长时间空闲时间的东西。欢迎任何帮助。
提前谢谢你,彼得