libevent

Is there any modern review of solutions to the 10000 client/sec problem

删除回忆录丶 提交于 2019-12-17 21:46:40
问题 (Commonly called the C10K problem) Is there a more contemporary review of solutions to the c10k problem (Last updated: 2 Sept 2006), specifically focused on Linux (epoll, signalfd, eventfd, timerfd..) and libraries like libev or libevent? Something that discusses all the solved and still unsolved issues on a modern Linux server? 回答1: The C10K problem generally assumes you're trying to optimize a single server, but as your referenced article points out "hardware is no longer the bottleneck".

Memcached数据库群集

余生长醉 提交于 2019-12-17 20:14:32
Memcached概述 一套开源的高性能分布式内存对象缓存系统 所有的数据都存储在内存中 支持任意存储类型的数据 提高网址访问的速度 Memcached缓存机制 当程序写入缓存数据请求时,Memcached的API接口将KEY输入路由算法模块路由到集群中的一台服务,之后由API接口与服务器进行通信,完成一次分布式缓存写入 Key索引建立在API中,值value数据存在后面的memcached中 Memcached分布式 要依赖于Memcached的客户端来实现 多个Memcached服务器是独立的 分布式数据如何存储是路由算法所决定 Memcached路由算法 求余数hash算法 先用key做hash运算的到一个整数,再去做hash算法,根据余数进行路由。不适合在动态变化的环境中 一致性hash算法 按照hash算法把对应key通过一定hash算法处理后映射形成一个首尾接闭合循环,然后通过使用与对象存储一样的hash算法将机器也映射到环中,顺时针方向计算将所有对象存储到离自己最近的机器中。适合在动态变化中使用 Memcached是danga.com(运营LiveJournal的技术团队)开发的一套分布式内存对象缓存系统,用于在动态系统中减少数据库负载,提升性能。关于这个东西,相信很多人都用过,本文意在通过对memcached的实现及代码分析,获得对这个出色的开源软件更深入的了解

Memcached原理与部署

帅比萌擦擦* 提交于 2019-12-17 17:28:39
Memcached概述 一套开源的高性能分布式内存对象缓存系统 所有的数据都存储在内存中 支持任意存储类型的数据 提高网站的访问速度 Memcached常用架构 Memcached路由算法 ●求余数hash算法 先用key做hash运算得到一个整数,再去做hash算法,根据余数进行路 由,这种算法适合大多数据需求,但是不适合用在动态变化的环境中 ●一致性hash算法 按照hash算法把对应的key通过一定的hash算法处理后映射形成一一个首 尾相接闭合循环,然后通过使用与对象存储一样的hash算法将机器也映 射到环中,顺时针方向计算将所有对象存储到里自己最近的机器中 适合在动态变化的环境中使用 环境部署 服务器角色 IP地址 需要安装的软件包 Memcached服务器 192.168.142.139 memcached-1.5.6.tar.gz、libevent-2.1.8-stable.tar.gz Memcache客户端 192.168.142.130 memcache-2.2.7.tgz 、LAMP(httpd、mysql、php) 第一步:配置Memcached服务器 1.安装编译环境 [root@server ~]# yum install gcc gcc-c++ make -y 2.远程挂载获取资源包 [root@server ~]# mount.cifs //192

Memcached 主主复制 + Keepalived 高可用架构【附上原理】

妖精的绣舞 提交于 2019-12-14 23:32:42
目录: 1·Memcached 主主复制概念 2·Memcached 高可用的实现 3·案例部署 4·总结 Memcached 主主复制概念 (1)主主复制概念: Memcached 主主复制是指在任意一台 Memcached 服务器修改数据都会被同步到另外一台,但是 Memcached API 客户端无法判断连接到那一台 Memcached 服务器,所有需要设置 VIP 地址,提供给 Memcached API 客户端进行连接。 (2)文章推荐: 知道了主主复制,那么需要了解 Memcached 是什么,还有一些最基本的情况,比如: 1) Memcached 功能 2)Memcached 特征 3)Memcached 储存方式 可以看看上篇文章 Memcached 高性能缓存对象 Memcached 高可用的实现 (1)怎么实现 Memcached 的高可用 1)这里就需要牵扯到主主复制的概念了,因为Memcached 主主复制这种架构,在程序连接的时候不会知道应该连接哪一个主服务器,所以需要在前端加上 VIP 地址,实现高可用架构。这里可以用 Keepalived 实现,所以说,Keepalived 的作用就是来检测 Memcached 服务器的状态是否正常。 2)Keepalived 会不断的检测 Memcached 主服务器的 11211端口,如果检测到 Memcached

Multi-threaded HTTP server with libevent

穿精又带淫゛_ 提交于 2019-12-13 04:49:49
问题 I'm trying to get a simple HTTP server done with libevent and managed to do it based on the documentation examples. However, without threads, the whole purpose of libevent is garbage. I'm not very experienced with threads in C++11, but i would love to know how to properly implement such server. I found this example online: https://gist.github.com/kzk/665437 Is this correct? Is pthreads the proper choice? Also, this line is very strange: for (int i = 0; i < nthreads; i++) { pthread_join(ths[i]

libevent笔记6:ssl bufferevent

笑着哭i 提交于 2019-12-13 02:28:42
Libevent另外提供了基于openssl的bufferevent来支持ssl,通过特殊的ssl bufferevent来对数据进行加密。 ps:本文不对openssl相应的接口做介绍 因为不熟 SSL bufferevent相关函数 struct bufferevent bufferevent_openssl_socket_new(struct event_base base, evutil_socket_t fd, struct ssl_st *ssl, enum bufferevent_ssl_state state, int options) 该函数能够基于给定的文件描述符及ssl对象创建一个ssl bufferevent。其中,bufferevent_ssl_state state参数表明了该bufferevent的角色,在作为服务端时一般使用BUFFEREVENT_SSL_ACCEPTING,在作为客户端时一般使用BUFFEREVENT_SSL_CONNECTING。 struct bufferevent bufferevent_openssl_filter_new(struct event_base base, struct bufferevent underlying, struct ssl_st ssl, enum bufferevent_ssl_state

memcached 集群搭建 magent+keepalived

十年热恋 提交于 2019-12-11 20:07:46
memcached安装 M 192.168.10.252 S 192.168.10.253 cd /tmp #安装环境 yum install gcc gcc-c++ make -y #下载 libevent-2.1.8-stable.tar.gz http://libevent.org/ #解压 tar xf libevent-2.1.8-stable.tar.gz -C /opt cd /opt/libevent-2.1.8-stable/ ./configure --prefix=/usr/local/libevent make && make install #下载memcached安装包 cd /tmp wget https://memcached.org/files/memcached-1.5.20.tar.gz tar xf memcached-1.5.20.tar.gz -C /opt/ cd /opt/memcached-1.5.20/ ./configure \ --prefix=/usr/local/memcached \ --with-libevent=/usr/local/libevent/ make && make install #memcached 复制功能需要模块 ln -s /usr/local/libevent/lib/libevent-2.1

CentOs 6, Php7.1, libevent, nginx returns 502

喜欢而已 提交于 2019-12-11 17:46:12
问题 I am upgrading laravel web application from php5.6 to php7.1 which leads me to upgrading libevent module. Application is async ans based on react library. So I ended with installed: PHP 7.1.12, libevent: 2.1.8 + expressif/pecl-event-libevent. And I have stable "502 Bad Gateway" from nginx. Without libevent (ReactStreamLoop) or on PHP 5.6 + libevent:1.4 works fine. Request lands to index.php and something happens later, inside of starting application. nginx log: 2017/11/24 10:41:24 [error]

libevent EVLOOP_NO_EXIT_ON_EMPTY not working?

你离开我真会死。 提交于 2019-12-11 12:04:49
问题 I don't understand how the EVLOOP_NO_EXIT_ON_EMPTY flag is supposed to work in version 2.1.x of libevent. If I don't add any events to my event_base the event_base_loop(my_base, EVLOOP_NO_EXIT_ON_EMPTY); call returns immediately which is not at all what I think it's supposed to do. If I add an event it loops with that pending event until it get's active but then the loop exits which I hoped would not happen. Goal: Have a named pipe open and libevent listening for a read. Whenever I echo

Serving large files (>2GB) with libevent on 32-bit system

拈花ヽ惹草 提交于 2019-12-11 09:02:25
问题 Preamble: lightweight http server written in C based on libevent v2 (evhttp), Linux, ARM, glibc2.3.4 I'm trying to serve big files (over 2GB) using evbuffer_add_file() on 32 bit system. The libevent was compiled with -D_FILE_OFFSET_BITS=64 flag. Here is the simplified code: int fd = -1; if ((fd = open(path, O_RDONLY)) < 0) { // error handling } struct stat st; if (fstat(fd, &st) < 0) { // error handling } struct evbuffer *buffer = evbuffer_new(); evbuffer_set_flags(buffer, EVBUFFER_FLAG