当前位置: 首页 > news >正文

腾讯广告卖东西怎么建设网站深汕特别合作区事务员待遇

腾讯广告卖东西怎么建设网站,深汕特别合作区事务员待遇,永久二级域名分发平台,深圳专业网站建设公司哪家好应用场景 有时为了保证可用性,需要同时访问两路服务,哪个先返回就取哪个。在brpc中,这有多种做法,根据server是否挂在同一个命名服务内有所区别。 当后端server可以挂在一个命名服务内时 Channel开启backup request。这个Channel会先向其中一个server发送请求,如果在Ch…应用场景 有时为了保证可用性,需要同时访问两路服务,哪个先返回就取哪个。在brpc中,这有多种做法,根据server是否挂在同一个命名服务内有所区别。 当后端server可以挂在一个命名服务内时 Channel开启backup request。这个Channel会先向其中一个server发送请求,如果在ChannelOptions.backup_request_ms后还没回来,再向另一个server发送。之后哪个先回来就取哪个。在设置了合理的backup_request_ms后,大部分时候只会发一个请求,对后端服务只有一倍压力。 #include gflags/gflags.h #include butil/logging.h #include butil/time.h #include brpc/channel.h #include "echo.pb.h"DEFINE_string(protocol, "baidu_std", "Protocol type. Defined in src/brpc/options.proto"); DEFINE_string(connection_type, "", "Connection type. Available values: single, pooled, short"); DEFINE_string(server, "0.0.0.0:8000", "IP Address of server"); DEFINE_string(load_balancer, "", "The algorithm for load balancing"); DEFINE_int32(timeout_ms, 100, "RPC timeout in milliseconds"); DEFINE_int32(max_retry, 3, "Max retries(not including the first RPC)"); DEFINE_int32(backup_request_ms, 2, "Timeout for sending backup request");int main(int argc, char* argv[]) {// Parse gflags. We recommend you to use gflags as well.GFLAGS_NS::ParseCommandLineFlags(argc, argv, true);// A Channel represents a communication line to a Server. Notice that // Channel is thread-safe and can be shared by all threads in your program.brpc::Channel channel;// Initialize the channel, NULL means using default options.brpc::ChannelOptions options;options.protocol = FLAGS_protocol;options.connection_type = FLAGS_connection_type;options.timeout_ms = FLAGS_timeout_ms/*milliseconds*/;options.max_retry = FLAGS_max_retry;// 设置backup_request_ms参数,在超时后会自动向另外一个server重发请求,与首次请求一起,哪个先返回用哪个options.backup_request_ms = FLAGS_backup_request_ms;if (channel.Init(FLAGS_server.c_str(), FLAGS_load_balancer.c_str(), options) != 0) {LOG(ERROR) "Fail to initialize channel";return -1;}// Normally, you should not call a Channel directly, but instead construct// a stub Service wrapping it. stub can be shared by all threads as well.example::EchoService_Stub stub(channel);// Send a request and wait for the response every 1 second.int counter = 0;while (!brpc::IsAskedToQuit()) {// We will receive response synchronously, safe to put variables// on stack.example::EchoRequest request;example::EchoResponse response;brpc::Controller cntl;request.set_index(++counter);// Because `done'(last parameter) is NULL, this function waits until// the response comes back or error occurs(including timedout).stub.Echo(cntl, request, response, NULL);if (!cntl.Failed()) {LOG(INFO) "Received response[index=" response.index() "] from " cntl.remote_side() " to " cntl.local_side() " latency=" cntl.latency_us() "us";} else {LOG(WARNING) cntl.ErrorText();}sleep(1);}LOG(INFO) "EchoClient is going to quit";return 0; }backup_request_ms推荐值 backup_request_ms=2ms可以大约覆盖95.5%的请求,选择backup_request_ms=10ms则可以覆盖99.99%的请求。 当后端server不能挂在一个命名服务内时 方案一、使用SelectiveChannel: 建立一个开启backup request的SelectiveChannel,其中包含两个sub channel。访问这个SelectiveChannel和上面的情况类似,会先访问一个sub channel,如果在ChannelOptions.backup_request_ms后没返回,再访问另一个sub channel。如果一个sub channel对应一个集群,这个方法就是在两个集群间做互备。 #include gflags/gflags.h #include bthread/bthread.h #include butil/logging.h #include brpc/selective_channel.h #include brpc/parallel_channel.h #include "echo.pb.h"DEFINE_int32(thread_num, 50, "Number of threads to send requests"); DEFINE_bool(use_bthread, false, "Use bthread to send requests"); DEFINE_int32(attachment_size, 0, "Carry so many byte attachment along with requests"); DEFINE_int32(request_size, 16, "Bytes of each request"); DEFINE_string(connection_type, "", "Connection type. Available values: single, pooled, short"); DEFINE_string(protocol, "baidu_std", "Protocol type. Defined in src/brpc/options.proto"); DEFINE_string(starting_server, "0.0.0.0:8114", "IP Address of the first server, port of i-th server is `first-port + i'"); DEFINE_string(load_balancer, "rr", "Name of load balancer"); DEFINE_int32
http://www.w-s-a.com/news/186148/

相关文章:

  • 跟我一起做网站嘉兴做网站哪家好
  • 上海知名建站公司山东住房和建设庭网站
  • 深圳市城乡建设部网站首页平台设计方案怎么做
  • 深圳美食教学网站制作wordpress列表图显示标题
  • 怎么做网址导航网站沈阳高端做网站建设
  • 棋牌网站开发需要多少钱整网站代码 带数据 免费 下载
  • 网站建设 sql 模版猎头用什么网站做单
  • 河北保定建设工程信息网站wordpress 远程缓存
  • 手机网站开发之列表开发win7网站开发教程
  • 楚雄市住房和城乡建设局网站廊坊企业网站建设
  • 东莞规划局官方网站wordpress添加文章页不显示图片
  • 做企业网站要哪些人员百度商城网站建设
  • c语言软件开和网站开发区别多产品的网站怎么做seo
  • 收益网站制作移动互联网应用的使用情况表格
  • 专业的手机网站建设公司哪家好同城信息网站建设
  • 参与做网站的收获国外网站服务器建设
  • 西宁网站建设报价cu君博规范网站kv如何做
  • 毕业室内设计代做网站广东建设监理协会网站个人账号
  • 百度推广点击收费标准自己如何做网站优化
  • 安徽省建设监理网站广州澄网站建设公司
  • 做简历用什么网站俄罗斯搜索引擎浏览器官网入口
  • dw里响应式网站怎么做制作网站需要多少时间
  • 网站如何做双链路示范学校建设专题网站
  • 网站开发北京影视网站seo描述
  • 高端网站定制建设公司哪家好企业网络推广技巧
  • 建设公司网站的内容建筑设计图片
  • 用ps怎么做网站的效果图互联网营销师报名入口官网
  • 网站的后端怎么开发网站 白名单
  • 济宁中小企业网站建设wordpress爆破工具
  • 零基础网站建设视频商城系统平台有哪些