[英]Why is this java program running in IIS via PHP/FastCGI much slower than in shell?
今天,我遇到了一個行為異常的Java程序。
在cmd shell中測試運行Java程序會導致非常快速的執行(〜0.5s)。 通過IIS使用PHP腳本訪問相同的Java,每個請求的等待時間為5.5s。
我在Java調用中添加了-Xprof,以查看其行為,並發現了如下重復模式:
Flat profile of 0.25 secs (24 total ticks): SeedGenerator Thread
Thread-local ticks:
100.0% 24 Blocked (of total)
最后,我們得到以下時間結果:
Thread-local ticks:
91.4% 448 Blocked (of total)
2.4% 1 Unknown: no last frame
lat profile of 5.04 secs (452 total ticks): SeedGenerator Thread
Interpreted + native Method
0.2% 0 + 1 java.lang.Object.notifyAll
0.2% 0 + 1 Total interpreted
Compiled + native Method
99.6% 27 + 423 sun.security.provider.SeedGenerator$ThreadedSeedGenerator.run
99.6% 27 + 423 Total compiled
Stub + native Method
0.2% 0 + 1 java.lang.System.currentTimeMillis
0.2% 0 + 1 Total stub
Global summary of 5.55 seconds:
100.0% 492 Received ticks
1.8% 9 Compilation
0.2% 1 Other VM operations
0.6% 3 Unknown code
代碼在SeedGenerator中花費5秒鍾,在此期間java.exe消耗了一個完整的cpu線程。 我嘗試在啟用或禁用模擬的情況下運行FastCGI,但不會更改結果。
FastCGI模塊如何產生新線程似乎有一些特定的東西。 我的第一個猜測是為模仿創建用戶環境需要很長時間,但是正如問題所示,這是不正確的。 但是,在尋找SeedGenerator的問題時,我遇到了以下答案: 插入USB熱點后,簡單Java程序的速度慢了100倍
通過更改java.security來使用建議的修復程序,可以將執行時間降低到期望值:
Global summary of 0.53 seconds:
100.0% 43 Received ticks
14.0% 6 Compilation
4.7% 2 Class loader
7.0% 3 Unknown code
從觀察到的行為來看,似乎合理的假設是,在帶有FastCGI的IIS上使用PHP在shell_exec上創建新進程不會提供任何提供程序sun.security.provider.Sun可用於生成足夠的熵來使用加密函數的功能,因此會暫停執行直到創建足夠的熵。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.