1

I had done simple setup:
Backend(website): 1 machine having tomcat installed and serving on 8080.
webapps folder of tomcat has two folder

1 withGoogleRule1
       |--test.html
2 withoutGoogleRule1
       |--test.html

Now i have a google-load-balancer setup with below settings

enter image description here

Now Backend machine direct ip is http://104.197.37.171:8080/withoutGoogleRule1/test.html

Load Balancer url is http://107.178.240.39:8080/withoutGoogleRule1/test.html

PROBLEM:

No matter how many time we refresh url for direct machine, all requests always servers correctly.

But if you access url using load balancer 1 out of 5 time it shows

The requested URL /withoutGoogleRule1/test.html was not found on this server.

Details:

Youtube Video showing the failure of request

PS:

Instance group details:

enter image description here

LoadBalancer backend details

enter image description here

Community
  • 1
  • 1
Bhuvan
  • 4,028
  • 6
  • 42
  • 84
  • Could you elaborate on what "withGoogleRule1" and "withoutGoogleRule1" mean? What is your intention here? I am confused, you configured the URL map for withGoogleRule1, but you were trying to access withoutGoogleRule1. – Dagang Sep 21 '16 at 16:33
  • You can check your Tomcat log to make sure if the 404 was returned by itself or the load balancer. – Dagang Sep 21 '16 at 17:21
  • What is the type of your instance group? Managed or unmanaged? – Dagang Sep 21 '16 at 17:23
  • I noticed in your instance group and backend service, you mapped http to 80 and 8080. And in the health check, you used port 80. – Dagang Sep 21 '16 at 17:38
  • "withGoogleRule1" and "withoutGoogleRule1" are just for testing purpose.. "withGoogleRule1" is a url which is added in google "host and path".... "withoutGoogleRule1" is a url which is not added in host and path section of google. – Bhuvan Sep 21 '16 at 17:47
  • tomcat access log does not have any request log when the request fail. – Bhuvan Sep 21 '16 at 17:48
  • instances are managed – Bhuvan Sep 21 '16 at 17:48
  • " you mapped http to 80 and 8080. And in the health check, you used port 80" ... yes that is correct... does it create any problem. – Bhuvan Sep 21 '16 at 17:50
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/123884/discussion-between-user2410148-and-dagang). – Bhuvan Sep 21 '16 at 18:52

1 Answers1

1

If your Tomcat was listening only on 8080 instead of 80, then the instance group, backend service configs were problematic. In particular, the health check was configured to check port 80, which would make the load balancer think the backend service was not healthy and return 404.

In addition, you can check Tomcat log to see how many requests were received and what were the responses.

Edit: Since you confirmed another process was listening on 80. The reason for 404 NOT FOUND could be, the requests were dispatched internally to 80. You can verify this theory by hosting a page on both 80 and 8080, e.g. /a.html, but the content is different, one is "i'm 80", the other is "i'm 8080". This way, you can know exactly what happened. Checking the log of the process listening on 80 can also help.

Dagang
  • 24,586
  • 26
  • 88
  • 133
  • thanks for pointing out ...but i see a strange behavior..i had a httpd server at port 80, so the instance was always healthy... and the above mention behaviour continue....next i just remove 80 from "edit instance group" section and now it do not fail the request randomly.. what can be the reason – Bhuvan Sep 21 '16 at 18:52
  • You are correct .. i followed your experiment and now when i refresh it show "i m 80" sometime and sometime "i m 8080"... so basically the conclusion is that the backend service send the request to backend using all port mention in "named port" section of a instance group...right?... i dont find any documentation explaining the named port section and port field while editing the backend section in load balancer ....i will ask another question specifically regarding named ports – Bhuvan Sep 22 '16 at 03:15