Hi:
My http api server run about 3 ~ 10 hours, then it terminated. There were no error messages. Could somebody help me to find the problem.
The program run on a ECS instance @ AliYun Cloud in China.
The program use the following libraries.
"robfig/cron"
"go-gorp/gorp"
"julienschmidt/httprouter"
_ "go-sql-driver/mysql"
I use
resp, err := http.Get("http://api.wunderground.com/api/xxx)
to get weather data every 10 mins.
then store in a struct.
The client can access at the following http get request.
“http://myproj-name.xyz:7000/api/0.2/weather”
response body like the following.
{
"Observation_time": "2018-04-03T10:41:57+08:00",
"Create_time": "2018-04-03T10:50:00.000139373+08:00",
"City": "Changzhou",
"Country_name": "China",
"Temp_c": 26,
"Relative_humidity": "62",
"Icon": "clear",
"Weather": "Clear",
"Wind_dir": "SSE",
"Wind_degrees": 0,
"Wind_kph": 11,
"Is_weather_site_alive": true
}
I store MySQL also on RDS @ AliYun Cloud in China
type Weather struct {
Observation_time time.Time
Create_time time.Time
City string `db:",size:64"`
Country_name string `db:",size:64"`
Temp_c int32 // for some problem that gorp reflect float32 to double schema
Relative_humidity string `db:",size:32"`
Icon string `db:",size:32"` // correct name for weather icon
Weather string `db:",size:64"` // "Clear"
Wind_dir string `db:",size:32"` // "South", "SSE"
Wind_degrees int32
Wind_kph int32
Is_weather_site_alive bool
}
It pass the stress test
$ab -n 10000 -c 1000 my-http-site-above
The cpu usage is about 5%, there are still 3GB avail memery on 4GB RAM.
Could someone help me to find the problem?
Thank you in advance.