keep-alive

httpClient不是单例的导致OOM

萝らか妹 提交于 2019-12-22 10:48:05
案发现场 昨天晚上突然短信收到 APM (即 Application Performance Management 的简称,我们内部自己搭建了这样一套系统来对应用的性能、可靠性进行线上的监控和预警的一种机制)大量告警 画外音: 监控是一种非常重要的发现问题的手段,没有的话一定要及时建立哦 紧接着运维打来电话告知线上部署的四台机器全部 OOM (out of memory, 内存不足),服务全部不可用,赶紧查看问题! 问题排查 首先运维先重启了机器,保证线上服务可用,然后再仔细地看了下线上的日志,确实是因为 OOM 导致服务不可用 第一时间想到 dump 当时的内存状态,但由于为了让线上尽快恢复服务,运维重启了机器,导致无法 dump 出事发时的内存。所以我又看了下我们 APM 中对 JVM 的监控图表 不看不知道,一看吓一跳,从 16:00 开始应用中创建的线程居然每时每刻都在上升,一直到 3w 左右,重启后(蓝色箭头),线程也一直在不断增长),正常情况下的线程数是多少呢,600! 问题找到了,应该是在下午 16:00 左右发了一段有问题的代码,导致线程一直在创建,且创建的线程一直未消亡! 查看发布记录,发现发布记录只有这么一段可疑的代码 diff:在 HttpClient 初始化的时候额外加了一个 evictExpiredConnections 配置 问题定位了

IIS 7.5: Force Keep Alive header in Response

陌路散爱 提交于 2019-12-21 10:48:37
问题 Based on my research, IIS 7.5 doesn't include the Connection:Keep-Alive in its response for reasons described here. Unfortunately, I have a non conforming client connecting to my web service that won't reuse sockets unless it sees Connection:Keep-Alive in the response header. I've tried programmatically adding this header but IIS appears to purposely strip it out. Is there any other way that I can force this header to be sent back to my naughty client? 回答1: I opened a support ticket with

IIS 7.5: Force Keep Alive header in Response

时光总嘲笑我的痴心妄想 提交于 2019-12-21 10:48:21
问题 Based on my research, IIS 7.5 doesn't include the Connection:Keep-Alive in its response for reasons described here. Unfortunately, I have a non conforming client connecting to my web service that won't reuse sockets unless it sees Connection:Keep-Alive in the response header. I've tried programmatically adding this header but IIS appears to purposely strip it out. Is there any other way that I can force this header to be sent back to my naughty client? 回答1: I opened a support ticket with

缓存keep-alive

断了今生、忘了曾经 提交于 2019-12-20 00:41:00
keep-alive 缓存 如果没有缓存,每点击一次导航,内容区就会创建一个组件,该组件会经历整个生命周期,每点击一次,就会创建一个组件,比较浪费性能, 这时,我们就要考虑到是否能将点击过的已创建的组件进行缓存,当再次点击已访问过的组件时,这时,就会从缓存中获取该组件,而不会重新创建,这就用到 keep-alive。 用 keep-alive 标签包裹 component 组件标签 <keep-alive :include = "whiteList " :exclude = "blackList " :max = "amount " > <component :is = "currentComponent " > </component > </keep-alive > 在vue-router中的应用 <keep-alive :include = "whiteList " :exclude = "blackList " :max = "amount " > <router-view > </router-view > </keep-alive > include 定义缓存白名单,keep-alive会缓存命中的组件; exclude 定义缓存黑名单,被命中的组件将不会被缓存; max 定义缓存组件上限,超出上限使用LRU的策略置换缓存数据。 Activated

vue组件name的作用

谁说我不能喝 提交于 2019-12-19 14:22:19
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 我们在写vue项目的时候会遇到给组件命名 这里的name非必选项,看起来好像没啥用处,但是实际上这里用处还挺多的 export default { name:'xxx' } 1.当项目使用keep-alive时,可搭配组件name进行缓存过滤 举个例子: 我们有个组件命名为detail,其中dom加载完毕后我们在钩子函数mounted中进行数据加载 export default { name:'Detail' }, mounted(){ this.getInfo(); }, methods:{ getInfo(){ axios.get('/xx/detail.json',{ params:{ id:this.$route.params.id } }).then(this.getInfoSucc) } } 因为我们在App.vue中使用了keep-alive导致我们第二次进入的时候页面不会重新请求,即触发mounted函数。 有两个解决方案,一个增加activated()函数,每次进入新页面的时候再获取一次数据。 还有个方案就是在keep-alive中增加一个过滤,如下图所示: <div id="app"> <keep-alive exclude="Detail"> <router-view/> </keep

Windows TCP socket has SO_KEEPALIVE enabled by default?

廉价感情. 提交于 2019-12-19 10:29:50
问题 I've encountered a strange bug with TCP sockets. It seems that SO_KEEPALIVE is enabled on all sockets by default. I wrote a short test case to create a socket and connect to a server. Immediately after the connect, I check SO_KEEPALIVE with getsockopt . The value is non-zero, which according to the MSDN, means keep alive is enabled. Maybe I'm misunderstanding this. I recently had a strange bug where a server disconnected twice in a row. Some clients were in a state where they had sent logon

Connection: Keep-Alive

吃可爱长大的小学妹 提交于 2019-12-18 17:31:28
上午在实验室看书,师弟让我帮忙解决个项目上的问题,问题不难,于是我教他抓包解决,让他电脑下了fiddler不过却显示不出来请求,我尝试了一下也是如此,过滤器也没开,突然意识到可能是360的问题,因为fiddler是通过http代理的方式,360很可能阻止第三方软件对浏览器代理,于是关掉360,重启浏览器终于能愉快的抓包了。 调试过程中我让他F12勾上disable cache,然后眼睛被一个词语吸引住了---Connection: Keep-Alive 当时很疑惑,http明明是无连接无状态的,那么这里的keepalive是指什么? 实际上它是一种TCP复用,每次http请求都需要tcp三次握手,浪费资源和时间,因此我们可以保持tcp通道连接一段时间,这样一次tcp连接就可以维持几次http请求。 在此基础上,还需要搞清楚几个其他的名词:长轮询,段轮询 长连接是为了tcp复用,那么这两个词是做什么的呢?先说个例子: 短轮询相信大家都不难理解,比如你现在要做一个电商中商品详情的页面,这个详情界面中有一个字段是库存量(相信这个大家都不陌生,随便打开淘宝或者京东都能找到这种页面)。而这个库存量需要实时的变化,保持和服务器里实际的库存一致,怎么实现? 长轮询这个时候就出现了,其实长轮询和短轮询最大的区别是,短轮询去服务端查询的时候,不管库存量有没有变化,服务器就立即返回结果了

HTTP: what are the relations between pipelining, keep-alive and Server Sent Events?

这一生的挚爱 提交于 2019-12-18 13:15:53
问题 I am trying to understand what are the HTTP pipelining and HTTP keep-alive connections, and trying to establish a connection between these two topics and Server Sent events technology. As far as I understand, HTTP keep-alive connection is the default in HTTP 1.1 way of using TCP when the established once TCP connection is used for sending several HTTP requests one by one. HTTP pipelining is the capability of client to send requests to server while responses to previous requests were not yet

Keep XMPP connection (using asmack) alive on Android

怎甘沉沦 提交于 2019-12-18 10:45:04
问题 I'm developing an application that receives push notifications via XMPP ( I know C2DM, but it has some limitations and I can't use because of it ), the problem is the connection that after some time is garbage collected and I can't send push notification to the Android device. I think I need to implement an Android service but I have no idea how to implement a service that would keep the connection alive. Somebody could help me? 回答1: I am not sure if "garbage collected" is the right term here

How to make Flask/ keep Ajax HTTP connection alive?

爱⌒轻易说出口 提交于 2019-12-18 04:08:28
问题 I have a jQuery Ajax call, like so: $("#tags").keyup(function(event) { $.ajax({url: "/terms", type: "POST", contentType: "application/json", data: JSON.stringify({"prefix": $("#tags").val() }), dataType: "json", success: function(response) { display_terms(response.terms); }, }); I have a Flask method like so: @app.route("/terms", methods=["POST"]) def terms_by_prefix(): req = flask.request.json tlist = terms.find_by_prefix(req["prefix"]) return flask.jsonify({'terms': tlist}) tcpdump shows