Reputation: 361
Our ELB is intermittently failing health checks on instances and throws errors "Environment health has transitioned from Ok to Warning. 2 out of 2 instances are impacted. See instance health for details" and after a minute it throws "Environment health has transitioned from Warning to Severe. ELB health is failing or not available for all instances"
It happens everyday on same time. Also I suspect that it happens whenever our CRON runs but I am not sure as it doesn't happens on other ELB instances.
I would like to know the root cause of this kind of problem as I searched through the forum and everyone had some different situations and cannot figure out what problem it would be for us.
This is our Production instance.
Upvotes: 23
Views: 32589
Reputation: 41
I have created an end point in my spring boot application as follows and deployed app to AWS Elastic Beanstalk. But still ELB health check fails.
package com.sme.controller;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class BaseController {
@GetMapping("/")
public ResponseEntity getServiceName(){
ResponseEntity responseEntity = new ResponseEntity(HttpStatus.OK);
return responseEntity;
}
}
Since I've configured spring security, does it affect on this ELB health check? Please check the following security configurations.
@Override
protected void configure(HttpSecurity http) throws Exception {
http.cors().and()
.csrf().disable()
.exceptionHandling().authenticationEntryPoint(unauthorizedHandler).and()
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS) // Since this is REST API no need to hold the sessions
.and()
.authorizeRequests()
//.antMatchers(SecurityConstants.SIGN_UP_URLS).permitAll()
.antMatchers("/**").permitAll()
.anyRequest().authenticated();
http.addFilterBefore(jwtAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class);
}
Upvotes: 2
Reputation: 1
create an endpoint for health check and send 200 status code. İf you want to use another path you should modify load balancer. example: "default 80 HTTP /" to default 80 HTTP "/ping"
Upvotes: 0
Reputation: 149
I had the same problem as you and followed Gökhan Ayhan's approach.
Modifying the load balancer from "default 80 HTTP /" to "default 80 HTTP /healthCheck" did not help, but you can also set the expected response code. I set it to 404 and it works, but this is not how this process is intended. Nevertheless I am only using a Load Balancer to get SSL on my Application, so it does not bother me.
a Load balancer is intended to balance out the load on the connected nodes, therefore it needs to be aware of the status of the individual nodes. If i understood correctly, this is done by the Health Checker process. You can configure that process as described above, or you give the balancer an actual endpoint to evaluate the health properly.
Upvotes: 3
Reputation: 1299
Application load balancer(a part of ELB) looking default "/" endpoint for health check and ELB gets 404 status code so ElasticBeanstalk instances turn red. You should create an endpoint for health check and send 200 status code. İf you want to use another path you should modify load balancer for example: "default 80 HTTP /" to "default 80 HTTP /healthCheck"
Upvotes: 47