TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

An alternative to fat JARs

73 点作者 javinpaul将近 9 年前

15 条评论

bradleybuda将近 9 年前
&gt; We have over 1,000 microservices constantly being built and deployed.<p>Wait until they find out how much faster in-process function calls are than RPCs.
评论 #11947420 未加载
评论 #11946650 未加载
评论 #11947301 未加载
评论 #11946744 未加载
exelius将近 9 年前
Everyone uses fat JARs because it removes a lot of things that can go wrong operationally (especially when standing up new servers).<p>The approach described in this article is the way Java was designed to work; but then everyone said you needed a &quot;self-executing&quot; service binary for portability. Enter the fat JAR, containers, orchestration layers, etc.<p>JVM application servers are certainly the way to go if you run a bunch of Java. But then you&#x27;re committing to maintaining a bunch of dependencies on your application servers, so really you&#x27;re pushing the tech debt down the line to your ops folks who now have to ensure dependencies are synced, maven servers running and updated properly, proxies punched for new external dependencies, etc.
pcl将近 9 年前
Cool! We&#x27;ve been doing something similar with public Maven repositories as the backing store.<p>Jonathan: if you&#x27;re listening, have you guys looked at Maven as a source instead of an S3 upload? What percentage of your dependencies are internal vs. external? We get 10-20x space savings from public-Maven-only elision.<p>EDIT: we&#x27;ve been working on a similar technique for executable JARs as well, which shares the same general optimization numbers and approach. It&#x27;s a bit trickier, since we want to preserve the same &#x27;java -jar&#x27; syntax, so requires a bit of classloader tomfoolery, and corresponding classloader awareness in code.
评论 #11946600 未加载
评论 #11946445 未加载
评论 #11946466 未加载
评论 #11946622 未加载
评论 #11946085 未加载
devsatish将近 9 年前
Back in the day , used to have all common dependency jars in server&#x2F;lib folder and only deploy slim application war to the server . Reminds me of this
评论 #11946376 未加载
评论 #11946352 未加载
sytringy05将近 9 年前
I did my first fat jar project in 2010 with embedded jersey and it was about 10mb. We use dropwizard now and most of our microservices sit at around 20mb which I think is still slim enough to avoid the extra overhead of managing the dependencies on deployment. IMHO Its hard to overstate how much benefit you get from java -jar
评论 #11946370 未加载
评论 #11946518 未加载
chadmaughan将近 9 年前
First thought (to the article title &quot;Why we stopped building fatjars&quot;) was that the build person had &quot;graduated&quot; and took their newly &quot;acquired superpowers elsewhere&quot; [0]<p>Joking aside, fantastic idea =)<p>Have you received a cease and desist from SlimFast yet for violating their trademark?<p>[0] - <a href="http:&#x2F;&#x2F;fortune.com&#x2F;disrupted-excerpt-hubspot-startup-dan-lyons&#x2F;" rel="nofollow">http:&#x2F;&#x2F;fortune.com&#x2F;disrupted-excerpt-hubspot-startup-dan-lyo...</a>
评论 #11947500 未加载
twic将近 9 年前
This sounds pretty sensible. I wonder if there&#x27;s a simple way to reproduce it. Maybe:<p><pre><code> I. Build your app as a thin JAR, with: a. a Main-Class entry in the manifest b. Class-Path entries in the manifest c. a file containing a list of dependency coordinates (group, artifact, version) in META-INF II. Write a shell script (for whatever value of &#x27;shell&#x27; you like) which: 1. takes a Maven repo URL and a Maven coordinate (group, artifact, version) 2. downloads the JAR from the repo, extracts its dependency list, then pulls its dependencies too 3. (optionally) somehow records which JAR is the main one, say by writing a tiny shell script or a symlink pointing at it </code></pre> You might be able to use a standard embedded POM instead of a dependency list, which might reduce the work a bit, but that would then require doing transitive dependency resolution at deploy time, which is probably a bad idea.<p>Phase I is something like 10 - 20 lines of Gradle, tops. You could pack it up into a plugin easily enough. Phase II is a similar amount of shell script, maybe more.<p>For extra safety, add SHA3 hashes to the dependency list file, and check them when you download the dependencies.<p>I&#x27;ve described this as using a Maven repo, but that doesn&#x27;t mean it has to hit Nexus or whatever; you can just put JARs in S3 in the right layout. A while ago, i was doing this by maintaining a repository locally, and just pushing the whole thing to a Bitbucket website:<p><a href="https:&#x2F;&#x2F;bitbucket.org&#x2F;twic&#x2F;twic.bitbucket.org&#x2F;src&#x2F;14ac48d4c4a9&#x2F;repository&#x2F;?at=default" rel="nofollow">https:&#x2F;&#x2F;bitbucket.org&#x2F;twic&#x2F;twic.bitbucket.org&#x2F;src&#x2F;14ac48d4c4...</a><p>You could do something similar, perhaps going from Nexus to S3.
评论 #11948292 未加载
setheron将近 9 年前
Here is something I mentioned on the reddit post:<p>You can go just as far with <a href="http:&#x2F;&#x2F;www.capsule.io&#x2F;" rel="nofollow">http:&#x2F;&#x2F;www.capsule.io&#x2F;</a> and the capulet to import dependencies with Maven (from a Nexus proxy that also fronts S3)<p>You are now deploying thin Jars and having the artifacts cached on the local host through maven~!
virmundi将近 9 年前
It&#x27;s neat. But is it worth it? I thought inbound for S3 was free so the 150 Mb doesn&#x27;t cost much. You&#x27;re paying $0.25 a month to store up to a gig of fat jars so really nkthing. It&#x27;s 20-ish seconds faster. Assuming a CI build, that doesn&#x27;t matter. It is a more complex solution. This makes it more brittle. Which makes it more bad. Finally you&#x27;re losing the single deployable. When something goes bad, you can&#x27;t just download the jar. You have to fish through the maven dependencies.
评论 #11946198 未加载
评论 #11946279 未加载
评论 #11946183 未加载
pacoverdi将近 9 年前
To deploy a process in my current project, I use Apache Ivy to resolve its dependencies (starting from a small set of top-level modules). Then I cache the results because Ivy resolution tends to take a while when you have a lot of dependencies and a lot of repositories.<p>Then I send a message to a remote agent with the command to run (classpath, main class, jvm args, args, configuration, etc). The agent then downloads the jars that are not already present in its cache with a valid SHA-1 checksum then starts.<p>Works quite well.
cmcginty将近 9 年前
Sounds like an interesting idea. I would be even more excited to see someone leverage Gradle for this. Assuming you publish your custom jar artifacts from your build server, your &quot;deployment artifact&quot; could be a single Gradle file that acts a your JAR dependency definition and execution wrapper. For deployment, sync the Gradle file and execute the wrapper to launch the service with Gradle handling all dependency updates and caching.
_pmf_将近 9 年前
Reinventing OSGi configurations.
评论 #11946367 未加载
mjt0229将近 9 年前
It doesn&#x27;t use S3, but you can do something similar with Coursier:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;alexarchambault&#x2F;coursier#launch" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;alexarchambault&#x2F;coursier#launch</a>
1138将近 9 年前
On limited information, this sounds like a work around on a root problem of runaway dependencies.<p>Maybe something like proguard could reduce deployable jar size to only the classes used.<p>I assume these are daily dev deploys and not production deploys.
评论 #11947049 未加载
matt_wulfeck将近 9 年前
It&#x27;s hard for me to understand why in 2016 200MB files are still any kind of real problem.
评论 #11946203 未加载