You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

上传速度受限,如何缩短远程测试服务器Jar包部署时间?

How to Cut Down Jar Deployment Time Over SSH on RHEL 6.5

Hey there, I feel your pain—15 minutes waiting for a jar upload every time you want to test is a huge drain on your workflow. Since you can't tweak the raw upload speed (thanks, client constraints!), let's focus on reducing the amount of data you need to transfer or finding smarter ways to deploy. Here are actionable steps tailored to your RHEL 6.5 environment:

1. Deploy Incrementally Instead of Full Jars

Instead of uploading the entire jar every time, only send the parts that changed. rsync is perfect for this—it checks file differences at the block level and only transfers what's new. Use this command:

rsync -avz --checksum your-app.jar user@test-server:/opt/app/
  • -a preserves permissions/ownership, -v gives verbose output, -z enables compression (helpful even for jars, since they often contain uncompressed metadata)
  • --checksum forces rsync to compare file content instead of just timestamps/size, which is critical if your build tool regenerates the jar with a new timestamp even when code changes are minimal

If your jar includes large, rarely changing dependencies (like Spring, Hibernate, etc.), split your deployment into two parts:

  • A static lib/ directory on the server with all dependency jars—upload these once, then never touch them again
  • Only upload your small, frequently changing application jar (or even just the compiled class files) to a separate directory, then update the classpath in your startup script to point to both

2. Build Directly on the Test Server

This is the biggest win if you can pull it off. Instead of building locally and uploading the jar, push your code changes to the server and build there. Here's how:

  1. Install JDK, Maven/Gradle (whichever you use in Eclipse) on the RHEL 6.5 server
  2. Set up a Git repo (or use rsync) to push only your code changes to the server—this is way smaller than a full jar
  3. Create a simple bash script to trigger builds and restart the app:
#!/bin/bash
cd /opt/app-source
git pull origin main
mvn clean package -DskipTests
cp target/your-app.jar /opt/app/
systemctl restart your-app.service

Now you just run this script after pushing code, and you skip the jar upload entirely.

3. Optimize SSH Compression

Even if you can't speed up the network, squeezing more data into each packet helps. Enable SSH compression for your transfers:

  • For scp: use the -C flag:
    scp -C your-app.jar user@test-server:/opt/app/
    
  • For regular SSH sessions, you can add this to your local ~/.ssh/config to auto-enable compression for this server:
    Host test-server
      HostName your-server-ip
      User your-username
      Compression yes
    

Note: If your jar is already heavily compressed (most are), this might only give a small boost—but it's free to try.

4. Cache Dependencies on the Server

If building on the server isn't an option, pre-cache all your project dependencies on the test server so you only upload your application code. For Maven:

  1. Copy your local ~/.m2/repository to the server's ~/.m2/repository once (this is a one-time upload, but since dependencies don't change often, it's worth it)
  2. When building locally, use mvn package -Dmaven.test.skip=true -Ddependency.locations.enabled=false to build a "thin jar" that only contains your code, not dependencies
  3. Upload this thin jar to the server, and run it with a classpath that includes the cached dependencies on the server

Once you have a few versions of your jar on the server, use symlinks to quickly switch between versions without re-uploading. For example:

  1. Upload new jars to /opt/app/versions/your-app-v1.2.3.jar
  2. Create a symlink /opt/app/current.jar that points to the active version
  3. When you upload a new version, just update the symlink:
    ln -sf /opt/app/versions/your-app-v1.2.4.jar /opt/app/current.jar
    

This doesn't reduce upload time, but it cuts down on post-upload setup time and makes rollbacks instant—super helpful for testing cycles.

Pick the option that fits your setup best—building on the server is the gold standard, but incremental rsync or splitting dependencies will still cut your wait time drastically.

内容的提问来源于stack exchange,提问作者Walter Colchado

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.13 08:13:52