Performance: Remoting vs. Web Services

本文探讨了HTTP与TCP在极端场景下的吞吐量对比,虽然TCP在某些情况下能提供更高的吞吐量,但HTTP因其广泛的应用和额外的功能(如代理、压缩和路由等)而更具优势。此外还讨论了Windows Service与IIS、二进制与SOAP、远程调用与Web服务之间的权衡。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

HTTP vs. TCP. Even though TCP squeezes out more throughput in extreme scenarios, it's hard to argue against the ubiquity of HTTP and port 80. It costs a little more, but you get proxies, compression, routing, and a lot more. Well worth it for the small cost.


Windows Service vs. IIS. Really the same argument as above. Like HTTP, IIS is such a well understood entity. It gives you a lot of free bonus functionality you wouldn't get in a vanilla service (think web farms for scalability). It's hard to justify not using it, given the minor performance hit.


Binary vs. SOAP. Binary is "poor man's compression". Plaintext/SOAP has the advantage of transparency, so if you can get a decent compression layer in there somewhere, you really don't need binary. I can't believe MS didn't include a compression layer in their remoting stack, so you might as well plan on using binary for now. This ties directly into the serialization time, which can be significant on large objects/datasets; the improvement in performance can be dramatic.


Remoting vs. Web Service. Where do I start? It depends how tightly coupled you want your application to be to your server-side API. Remoting is a little easier to get running with minimal work in the short term, but the long term benefits skew heavily towards Web Services. When you build a WS, you've built a truly generic HTTP interface layer that you can leverage for the forseeable future. This isn't a COM or CORBA flash in the pan.


[url]http://www.codinghorror.com/blog/archives/000049.html[/url]
### Jenkins JNLP Agent 远程连接失败解决方案 当遇到 `java.io.IOException: Connection refused` 的错误时,通常是因为目标端口不可达或者网络配置存在问题。以下是针对该问题的具体分析和解决方法: #### 1. 验证 Master 和 Agent 容器之间的网络连通性 确保 Jenkins 主服务器(Master)所在的容器 A 能够被代理节点(Agent)所在容器 B 正常访问。可以通过以下命令测试: ```bash ping <Master_IP> nc -zv <Master_IP> <Port> ``` 如果无法通过上述命令验证连通性,则可能是防火墙阻止了流量或 IP 地址不正确。 #### 2. 检查 Master 是否监听指定端口 确认 Jenkins Master 是否正在监听所需的端口号(默认为 50000)。可以使用以下命令检查: ```bash netstat -tuln | grep 50000 ``` 如果没有看到对应的监听记录,则说明 Jenkins 并未绑定到此端口[^1]。此时需修改 Jenkins 配置文件 `/etc/default/jenkins` 或 Docker 启动参数,添加如下选项以显式开启端口监听: ```bash --argumentsRealm.passwd.$USER=yourpassword --httpListenAddress=0.0.0.0 --ajp13Port=-1 ``` #### 3. 修改 Jenkins URL 设置 进入 Jenkins Web 控制台,在 **Manage Jenkins -> Configure Global Security** 页面中找到 “Agents” 部分,设置正确的 TCP 端口用于出站连接。推荐选择固定端口而非随机分配,并将其设为与实际使用的相同值(如 50000)[^2]。 #### 4. 下载并运行 Agent Jar 文件 按照官方文档指引获取最新版本的 agent.jar 文件至 Slave 节点机器上执行启动脚本: ```bash wget http://<JENKINS_MASTER_URL>/jnlpJars/agent.jar nohup java -jar agent.jar -jnlpUrl http://<JENKINS_MASTER_URL>/computer/<NODE_NAME>/slave-agent.jnlp \ -secret $(cat secrets.txt) -workDir "/path/to/workdir" & ``` 注意替换 `<JENKINS_MASTER_URL>` 及其他占位符的实际内容[^3]。 #### 5. 使用 WebSocket 替代传统 JNLP 协议 对于某些复杂环境下的跨网段通信场景,建议尝试切换到基于 WebSocket 的方式建立链接。这可通过调整 Node Configuration 中 Advanced Options 来实现。 --- ### 示例代码片段 下面是一个简单的 Shell Script 示例来自动化部署过程: ```bash #!/bin/bash MASTER="http://192.168.179.100:8080" AGENT_JAR="/tmp/agent.jar" if [ ! -f "$AGENT_JAR" ]; then echo "Downloading agent jar..." curl -o $AGENT_JAR ${MASTER}/jnlpJars/agent.jar || exit 1 fi exec java -jar $AGENT_JAR -jnlpUrl ${MASTER}/computer/my-node/slave-agent.jnlp \ -secret "$(cat /var/lib/jenkins/secrets/node_secret)" -workDir "${WORKDIR}" ``` ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值