【问题标题】:After Java 1.6.0_27 update Heroku application does not boot in 60 secondsJava 1.6.0_27 更新后 Heroku 应用程序在 60 秒内无法启动
【发布时间】:2013-04-09 08:37:00
【问题描述】:

当我使用 1.6.0_20 回滚到以前的版本时,我的应用程序会在 60 秒内启动。鉴于以下事实,我该如何调试和解决问题?

  • 我的应用程序使用的是 Play 1.2.5
  • 在日志中,我看到应用程序连接到 PostgreSQL 数据库。这通常是 R10 错误之前的最后一个日志。

--更新 我创建了一个插件并发出了一个假端口绑定,它将在 10 秒后关闭。这解决了绑定问题,但现在我遇到了内存问题。在高负载下可能应用程序正在使用 600M 的内存。但现在我看到 ~1500M,而且还在不断增加。

@Override
public void onConfigurationRead() {
    final int port = Integer.parseInt(Play.configuration.getProperty("http.port"));

    try {
        // Create a new server socket and set to non blocking mode
        final ServerSocketChannel ssc = ServerSocketChannel.open();
        ssc.configureBlocking(false);
        InetSocketAddress isa = new InetSocketAddress(port);
        ssc.socket().bind(isa);
        Logger.info("Fake bind to port %d", port);

        Timer timer = new Timer();
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                try {
                    ssc.socket().close();
                    Logger.info("Fake port closed");
                } catch (IOException ioe) {
                    Logger.error(ioe, "Cannot close fake port");
                }
            }
        }, 10000);
    } catch (IOException ioe) {
        Logger.error(ioe, "Cannot open fake port");
    }

    Cache.forcedCacheImpl = RedisCacheImpl.getInstance();
}   

【问题讨论】:

  • 您的应用启动时是否正在运行数据库迁移?如果是这样,你能把它们移到一个单独的过程中吗?
  • 不,在启动过程中没有什么比需要的。

标签: java heroku playframework


【解决方案1】:

我已切换到 jdk 7。我的应用程序现在可以在 40 秒内启动并使用 500-600MB 内存。我已将这个问题告知 Heroku,但他们并不在意。

【讨论】:

  • 我们在 heroku 上也遇到了内存问题 - JDK 7 还在解决您的问题吗?你是怎么换成7的?谢谢!
  • @MattHall 是的,JDK 7 对我来说很好。为了切换到 JDK 7,在项目的根目录中放置一个名为 system.properties 的文件,并将 java.runtime.version=1.7 放入其中。
猜你喜欢
  • 1970-01-01
  • 2020-02-10
  • 1970-01-01
  • 2018-05-26
  • 2013-03-19
  • 2016-03-08
  • 1970-01-01
  • 2019-12-07
相关资源
最近更新 更多