gpt4 book ai didi

tomcat - Gradle 在 Bamboo 服务器中构建缓慢

转载 作者:行者123 更新时间:2023-11-28 22:28:50 24 4
gpt4 key购买 nike

使用 gradle 脚本构建的项目。有一些测试需要启动应用程序上下文。

@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = ExceptionTestApplication.class)
@ActiveProfiles("headerCheck")
@WebIntegrationTest({ "server.port=0", "management.port=0" })
public class ExceptionTest {

本项目在本地1分钟即可搭建完成,在服务器端则需要数十分钟。打印build的debug信息后,发现step很吃时间。

使用 [SHA1PRNG] 创建用于 session ID 生成的 SecureRandom 实例花费了 [447,031] 毫秒。

09:25:01.630 [DEBUG] [TestEventLogger]     2015-06-06 09:25:01.628  INFO 27681 --- [ost-startStop-1] o.a.c.util.SessionIdGeneratorBase        : Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [447,031] milliseconds.

奇怪的是在本地构建时从来没有出现过这一步,所以我真的很困惑。

  • 在服务器上构建时如何以及为何调用 SecureRandom?
  • 如何配置服务器,才能达到本地一样的构建速度?

最佳答案

How and why SecureRandom is invoked when building on server?

这很难猜测,取决于您构建的细节,但请参阅下面的一些指示。

How to configure the server, so that can achieve the build speed just as local?

慢的原因是缺少entropy在服务器上,这是加密功能的重要要求:

Entropy can affect the cryptography (TLS/SSL) of a server: If it is too low then the regeneration of codes can take a long time to complete.

一般的服务器,尤其是云服务器,都缺乏用户输入和其他常见的随机熵源,需要相应地进行补偿。

背景

这里有一些链接,提供更多信息和各种处理方法(但请参阅下面的可能的即时解决方案):

解决方案

您只需要确保您的服务器有足够的可用熵。如何实现这一点当然取决于您的运行时环境,尤其是操作系统。就我个人而言,我正在为我们的 Amazon Linux AMI (CentOS based) 使用如下内容 Bamboo 代理:

# Seed entropy
sudo yum install rng-utils -y
sudo rngd -r /dev/urandom -o /dev/random

像这样播种熵后,它应该比以前高得多 - 测试如下:

cat /proc/sys/kernel/random/entropy_avail

亚马逊网络服务 (AWS) 随机生成器

如果您碰巧使用 AWS,您也可以使用专用的 GenerateRandom AWS Key Management Service (KMS) 提供的 API 操作,据称(在其他地方,目前没有引用资料)提供适用于加密目的的高质量随机数。

  • “高质量”声明在概念上受到了挑战,因为他们的算法没有记录,从透明的安全角度来看,这确实不是正确的方法 - 尽管存在这种有效的批评,但我个人相信 AWS 能够做到这一点不过,这并非最不重要的一点,因为对 security 采取了广泛的主动且通常有据可查的方法.

关于tomcat - Gradle 在 Bamboo 服务器中构建缓慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30683810/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com