2017-08-16 71 views
1

我已經在Google App Engine Flexible中部署了一個簡單的Spring引導應用程序。該應用程序。有兩個API,一個用於將用戶數據添加到數據庫(xxx.appspot.com/add),另一個用於從數據庫(xxx.appspot.com/all)獲取所有用戶數據。Google App Engine中的502服務器錯誤使用JMeter進行負載測試時靈活

我想知道GAE如何擴展負載,因此使用JMeter創建一個負載爲100秒的用戶併發性,並在10秒內提升,並在半秒鐘的時間內永遠調用這兩個API。雖然它在一段時間內運行良好(只有一個實例),但在「java.net.SocketException」或「服務器響應狀態爲502」30秒鐘後,它開始失敗。

此錯誤後,當我嘗試從瀏覽器訪問相同的API,它顯示,

Error: Server Error

The server encountered a temporary error and could not complete your request. Please try again in 30 seconds.

服務恢復正常後30分鐘左右,並且無論何時負載測試發生它重複與上述相同的行爲。我期望GAE根據負載進行自動調整,無需任何停機時間(使用多個實例),而只是崩潰或阻塞服務(日誌中沒有任何信息)。我的app.yaml配置是,

runtime: java 
env: flex 
service: hello-service 
automatic_scaling: 
    min_num_instances: 1 
    max_num_instances: 10 

我有點卡住了這個,任何幫助將不勝感激。提前致謝。

+0

你在日誌查看器中看到什麼? https://cloud.google.com/appengine/docs/flexible/python/writing-application-logs#viewing_logs –

+0

請參閱https://stackoverflow.com/questions/38012797/google-app-engine-502-bad-gateway -with-nodejs – user7294900

+0

@ user7294900我已將其更改爲app.yaml中的手動縮放。但是,我無法找到從控制檯中的「Google擁有」VM切換到「自己擁有」VM的方式。我無法在GCE區域找到實例。此外,我在日誌中獲得的詳細錯誤是在此鏈接* https://jpst.it/13hHk*。 – KingKari

回答

2

解決方案是增加資源配置,詳情如下。

Given that I did not set a resource parameter, it defaulted to the pre-defined values for both CPU and Memory. In this case, the default memory was set at 0.6GB. App Engine Flex instances uses about 0.4GB for overhead processes. Given Java is known to consume higher memory, there is a great likelihood that the overhead processes consumed more than the approximate 0.4GB value. Now instances in App Engine are restarted due to a variety of reasons including optimization due to memory use. This explains why your instances went off and it shows Tomcat is starting up (they got restarted) and ends up in 502 error due to the nginx is not able to complete the request. Fixing the above may lessen if not completely eliminate the 502s.

當我指定了資源屬性並增加了app.yaml 502中的配置後,錯誤似乎消失了。

+0

感謝KingKari!我有同樣的問題,不知道如何解決它你的如此lution爲我工作。 –

相關問題