У меня есть приложение Rails 5, запущенное на Heroku, которое работало довольно быстро, пока около трех недель назад я не установил Websolr для поиска клиентов.
С тех пор даже на страницах, где Solr не используетсяУ меня случайное время отклика.Ниже приведен запрос, загрузка которого заняла чуть более минуты.Я действительно понимаю, что мне нужно выполнить некоторую загруженную загрузку, но даже выполнение базовых объединений и поиск записей по идентификатору могут иногда занимать 30 секунд.Похоже, что мое выделение памяти в любой момент времени составляет около 30%, но я использую промежуточную базу данных ($ 9).Мои запросы к websolr тоже занимают много времени, так что это не только этот запрос.В моей базе данных около 5 тысяч записей о клиентах и еще восемь тысяч записей о работе.В каждый момент времени его используют только около 4 пользователей, поэтому у меня нет тонны трафика.
У меня три стандартные 1x динамограммы на 512 МБ ОЗУ.Мое время ответа в настоящее время показывает 30 секунд.
Dec 27 14:31:42 enigmatic-temple-38800 app/web.1: I, [2018-12-27T22:31:42.063716 #4] INFO -- : [f80358c4-cf90-4004-86c0-4389c9fbc264] Started
GET "/jobs?type=list" for 76.107.177.174 at 2018-12-27 22:31:42 +0000
Dec 27 14:31:42 enigmatic-temple-38800 app/web.1: I, [2018-12-27T22:31:42.066904 #4] INFO -- : [f80358c4-cf90-4004-86c0-4389c9fbc264]
Processing by JobsController#index as HTML
Dec 27 14:31:42 enigmatic-temple-38800 app/web.1: I, [2018-12-27T22:31:42.067042 #4] INFO -- : [f80358c4-cf90-4004-86c0-4389c9fbc264]
Parameters: {"type"=>"list"}
Dec 27 14:31:42 enigmatic-temple-38800 app/web.1: D, [2018-12-27T22:31:42.071352 #4] DEBUG -- : [f80358c4-cf90-4004-86c0-4389c9fbc264] User Load (1.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2 [["id", 9], ["LIMIT", 1]]
Dec 27 14:31:42 enigmatic-temple-38800 app/web.1: D, [2018-12-27T22:31:42.079628 #4] DEBUG -- : [f80358c4-cf90-4004-86c0-4389c9fbc264] Location Load (3.6ms) SELECT "locations".* FROM "locations" INNER JOIN "locations_users" ON "locations"."id" = "locations_users"."location_id" WHERE "locations_users"."user_id" = $1 AND "locations"."id" = $2 LIMIT $3 [["user_id", 9], ["id", 3], ["LIMIT", 1]]
Dec 27 14:31:42 enigmatic-temple-38800 app/web.1: D, [2018-12-27T22:31:42.086265 #4] DEBUG -- : [f80358c4-cf90-4004-86c0-4389c9fbc264] CACHE Location Load (0.3ms) SELECT "locations".* FROM "locations" INNER JOIN "locations_users" ON "locations"."id" = "locations_users"."location_id" WHERE "locations_users"."user_id" = $1 AND "locations"."id" = $2 LIMIT $3 [["user_id", 9], ["id", 3], ["LIMIT", 1]]
Dec 27 14:31:42 enigmatic-temple-38800 app/web.1: D, [2018-12-27T22:31:42.091018 #4] DEBUG -- : [f80358c4-cf90-4004-86c0-4389c9fbc264] CACHE Location Load (0.0ms) SELECT "locations".* FROM "locations" INNER JOIN "locations_users" ON "locations"."id" = "locations_users"."location_id" WHERE "locations_users"."user_id" = $1 AND "locations"."id" = $2 LIMIT $3 [["user_id", 9], ["id", 3], ["LIMIT", 1]]
Dec 27 14:32:12 enigmatic-temple-38800 heroku/router: at=error code=H12 desc="Request timeout" method=GET path="/jobs?type=list" host=se.desotomatrix.com request_id=f80358c4-cf90-4004-86c0-4389c9fbc264 fwd="76.107.177.174" dyno=web.1 connect=1ms service=30000ms status=503 bytes=0 protocol=https
Dec 27 14:32:48 enigmatic-temple-38800 app/web.1: D, [2018-12-27T22:32:47.950721 #4] DEBUG -- : [f80358c4-cf90-4004-86c0-4389c9fbc264] Job Load (65853.3ms) SELECT "jobs".* FROM "jobs" WHERE "jobs"."location_id" = $1 AND "jobs"."complete" = $2 ORDER BY "jobs"."start" DESC [["location_id", 3], ["complete", "f"]]
Dec 27 14:32:48 enigmatic-temple-38800 app/web.1: D, [2018-12-27T22:32:47.980830 #4] DEBUG -- : [f80358c4-cf90-4004-86c0-4389c9fbc264]
Customer Load (4.4ms) SELECT "customers".* FROM "customers" WHERE "customers"."id" IN (4441, 4907, 4912, 4598, 4925, 4909, 4497, 4579, 4772, 4470, 4469, 4506, 4778, 4487, 4543, 4491, 4542, 4771, 4479, 4445, 4577, 4868, 4703, 4283, 4587, 4910, 4570, 4379, 4591, 4481, 4558, 4460, 4583, 4492, 4393, 4399, 4483, 4557, 4564, 4924, 4406, 4519, 4387, 4467, 4547, 4545, 4905, 4490, 4867, 4285, 4443, 4402, 4830, 4853, 4854, 4838, 4503, 4864, 4568, 4601, 4573, 4388, 4300, 4468, 4303, 4433, 4781, 4758, 4692, 4400, 4561, 4509, 4390, 4773, 4299, 4649, 4767, 4546, 4296, 4755, 4380, 4751, 4446, 4501, 4749, 4428, 4294, 4559, 4571, 4463, 4682, 4404, 4421, 4677, 4667, 4495, 4657, 4521, 4539, 4396)
Dec 27 14:32:48 enigmatic-temple-38800 app/web.1: D, [2018-12-27T22:32:47.997759 #4] DEBUG -- : [f80358c4-cf90-4004-86c0-4389c9fbc264] Job Load (4.0ms) SELECT "jobs".* FROM "jobs" WHERE "jobs"."location_id" = $1 AND "jobs"."complete" = $2 ORDER BY "jobs"."start" DESC LIMIT $3 OFFSET $4 [["location_id", 3], ["complete", "f"], ["LIMIT", 20], ["OFFSET", 0]]
Dec 27 14:32:48 enigmatic-temple-38800 app/web.1: D, [2018-12-27T22:32:48.005336 #4] DEBUG -- : [f80358c4-cf90-4004-86c0-4389c9fbc264]
Customer Load (1.9ms) SELECT "customers".* FROM "customers" WHERE "customers"."id" IN (4441, 4907, 4912, 4598, 4925, 4909, 4497, 4579, 4772, 4470, 4469, 4778, 4506, 4487, 4491, 4543, 4542, 4771, 4479)
Dec 27 14:32:48 enigmatic-temple-38800 app/web.1: I, [2018-12-27T22:32:48.011759 #4] INFO -- : [f80358c4-cf90-4004-86c0-4389c9fbc264] Rendering jobs/list.html.erb within layouts/application
Dec 27 14:32:48 enigmatic-temple-38800 app/web.1: D, [2018-12-27T22:32:48.016673 #4] DEBUG -- : [f80358c4-cf90-4004-86c0-4389c9fbc264] CACHE Location Load (0.0ms) SELECT "locations".* FROM "locations" INNER JOIN "locations_users" ON "locations"."id" = "locations_users"."location_id" WHERE "locations_users"."user_id" = $1 AND "locations"."id" = $2 LIMIT $3 [["user_id", 9], ["id", 3], ["LIMIT", 1]]
Dec 27 14:32:48 enigmatic-temple-38800 app/web.1: D, [2018-12-27T22:32:48.018493 #4] DEBUG -- : [f80358c4-cf90-4004-86c0-4389c9fbc264] CACHE Location Load (0.0ms) SELECT "locations".* FROM "locations" INNER JOIN "locations_users" ON "locations"."id" = "locations_users"."location_id" WHERE "locations_users"."user_id" = $1 AND "locations"."id" = $2 LIMIT $3 [["user_id", 9], ["id", 3], ["LIMIT", 1]]
Dec 27 14:32:48 enigmatic-temple-38800 app/web.1: D, [2018-12-27T22:32:48.023237 #4] DEBUG -- : [f80358c4-cf90-4004-86c0-4389c9fbc264] User Load (2.0ms) SELECT "users".* FROM "users" INNER JOIN "locations_users" ON "users"."id" = "locations_users"."user_id" WHERE "locations_users"."location_id" = $1 ORDER BY "users"."active" DESC, "users"."first_name" ASC, "users"."last_name" ASC [["location_id", 3]]
Dec 27 14:32:48 enigmatic-temple-38800 app/web.1: D, [2018-12-27T22:32:48.029189 #4] DEBUG -- : [f80358c4-cf90-4004-86c0-4389c9fbc264] CACHE Job Load (0.0ms) SELECT "jobs".* FROM "jobs" WHERE "jobs"."location_id" = $1 AND "jobs"."complete" = $2 ORDER BY "jobs"."start" DESC LIMIT $3 OFFSET $4 [["location_id", 3], ["complete", "f"], ["LIMIT", 20], ["OFFSET", 0]]
Dec 27 14:32:48 enigmatic-temple-38800 app/web.1: D, [2018-12-27T22:32:48.034066 #4] DEBUG -- : [f80358c4-cf90-4004-86c0-4389c9fbc264] CACHE Customer Load (0.0ms) SELECT "customers".* FROM "customers" WHERE "customers"."id" IN (4441, 4907, 4912, 4598, 4925, 4909, 4497, 4579, 4772, 4470, 4469, 4778, 4506, 4487, 4491, 4543, 4542, 4771, 4479)
Dec 27 14:32:48 enigmatic-temple-38800 app/web.1: D, [2018-12-27T22:32:48.045456 #4] DEBUG -- : [f80358c4-cf90-4004-86c0-4389c9fbc264] User Load (2.7ms) SELECT "users".* FROM "users" INNER JOIN "jobs_users" ON "users"."id" = "jobs_users"."user_id" WHERE "jobs_users"."job_id" = $1 [["job_id", 4489]]
Dec 27 14:32:48 enigmatic-temple-38800 app/web.1: D, [2018-12-27T22:32:48.051725 #4] DEBUG -- : [f80358c4-cf90-4004-86c0-4389c9fbc264] User Load (2.5ms) SELECT "users".* FROM "users" INNER JOIN "jobs_users" ON "users"."id" = "jobs_users"."user_id" WHERE "jobs_users"."job_id" = $1 [["job_id", 4356]]
Dec 27 14:32:48 enigmatic-temple-38800 app/web.1: D, [2018-12-27T22:32:48.057895 #4] DEBUG -- : [f80358c4-cf90-4004-86c0-4389c9fbc264] User Load (2.6ms) SELECT "users".* FROM "users" INNER JOIN "jobs_users" ON "users"."id" = "jobs_users"."user_id" WHERE "jobs_users"."job_id" = $1 [["job_id", 4385]]
Dec 27 14:32:48 enigmatic-temple-38800 app/web.1: D, [2018-12-27T22:32:48.063389 #4] DEBUG -- : [f80358c4-cf90-4004-86c0-4389c9fbc264] User Load (2.2ms) SELECT "users".* FROM "users" INNER JOIN "jobs_users" ON "users"."id" = "jobs_users"."user_id" WHERE "jobs_users"."job_id" = $1 [["job_id", 4435]]
Dec 27 14:32:48 enigmatic-temple-38800 app/web.1: D, [2018-12-27T22:32:48.069918 #4] DEBUG -- : [f80358c4-cf90-4004-86c0-4389c9fbc264] User Load (2.5ms) SELECT "users".* FROM "users" INNER JOIN "jobs_users" ON "users"."id" = "jobs_users"."user_id" WHERE "jobs_users"."job_id" = $1 [["job_id", 4522]]
Dec 27 14:32:48 enigmatic-temple-38800 app/web.1: D, [2018-12-27T22:32:48.079469 #4] DEBUG -- : [f80358c4-cf90-4004-86c0-4389c9fbc264] User Load (6.0ms) SELECT "users".* FROM "users" INNER JOIN "jobs_users" ON "users"."id" = "jobs_users"."user_id" WHERE "jobs_users"."job_id" = $1 [["job_id", 4339]]
Dec 27 14:32:48 enigmatic-temple-38800 app/web.1: D, [2018-12-27T22:32:48.085798 #4] DEBUG -- : [f80358c4-cf90-4004-86c0-4389c9fbc264] User Load (2.7ms) SELECT "users".* FROM "users" INNER JOIN "jobs_users" ON "users"."id" = "jobs_users"."user_id" WHERE "jobs_users"."job_id" = $1 [["job_id", 3750]]
Dec 27 14:32:48 enigmatic-temple-38800 app/web.1: D, [2018-12-27T22:32:48.098776 #4] DEBUG -- : [f80358c4-cf90-4004-86c0-4389c9fbc264] User Load (8.5ms) SELECT "users".* FROM "users" INNER JOIN "jobs_users" ON "users"."id" = "jobs_users"."user_id" WHERE "jobs_users"."job_id" = $1 [["job_id", 3054]]
Dec 27 14:32:48 enigmatic-temple-38800 app/web.1: D, [2018-12-27T22:32:48.107149 #4] DEBUG -- : [f80358c4-cf90-4004-86c0-4389c9fbc264] User Load (2.2ms) SELECT "users".* FROM "users" INNER JOIN "jobs_users" ON "users"."id" = "jobs_users"."user_id" WHERE "jobs_users"."job_id" = $1 [["job_id", 3760]]
Dec 27 14:32:48 enigmatic-temple-38800 app/web.1: D, [2018-12-27T22:32:48.112650 #4] DEBUG -- : [f80358c4-cf90-4004-86c0-4389c9fbc264] User Load (2.2ms) SELECT "users".* FROM "users" INNER JOIN "jobs_users" ON "users"."id" = "jobs_users"."user_id" WHERE "jobs_users"."job_id" = $1 [["job_id", 3861]]
Dec 27 14:32:48 enigmatic-temple-38800 app/web.1: D, [2018-12-27T22:32:48.118784 #4] DEBUG -- : [f80358c4-cf90-4004-86c0-4389c9fbc264] User Load (2.1ms) SELECT "users".* FROM "users" INNER JOIN "jobs_users" ON "users"."id" = "jobs_users"."user_id" WHERE "jobs_users"."job_id" = $1 [["job_id", 3860]]
Dec 27 14:32:48 enigmatic-temple-38800 app/web.1: D, [2018-12-27T22:32:48.124535 #4] DEBUG -- : [f80358c4-cf90-4004-86c0-4389c9fbc264] User Load (2.5ms) SELECT "users".* FROM "users" INNER JOIN "jobs_users" ON "users"."id" = "jobs_users"."user_id" WHERE "jobs_users"."job_id" = $1 [["job_id", 3841]]
Dec 27 14:32:48 enigmatic-temple-38800 app/web.1: D, [2018-12-27T22:32:48.133110 #4] DEBUG -- : [f80358c4-cf90-4004-86c0-4389c9fbc264] User Load (2.3ms) SELECT "users".* FROM "users" INNER JOIN "jobs_users" ON "users"."id" = "jobs_users"."user_id" WHERE "jobs_users"."job_id" = $1 [["job_id", 3859]]
Dec 27 14:32:48 enigmatic-temple-38800 app/web.1: D, [2018-12-27T22:32:48.138101 #4] DEBUG -- : [f80358c4-cf90-4004-86c0-4389c9fbc264] User Load (1.7ms) SELECT "users".* FROM "users" INNER JOIN "jobs_users" ON "users"."id" = "jobs_users"."user_id" WHERE "jobs_users"."job_id" = $1
[["job_id", 3824]]
Dec 27 14:32:48 enigmatic-temple-38800 app/web.1: D, [2018-12-27T22:32:48.143769 #4] DEBUG -- : [f80358c4-cf90-4004-86c0-4389c9fbc264] User Load (1.7ms) SELECT "users".* FROM "users" INNER JOIN "jobs_users" ON "users"."id" = "jobs_users"."user_id" WHERE "jobs_users"."job_id" = $1 [["job_id", 3963]]
Dec 27 14:32:48 enigmatic-temple-38800 app/web.1: D, [2018-12-27T22:32:48.149058 #4] DEBUG -- : [f80358c4-cf90-4004-86c0-4389c9fbc264] User Load (2.4ms) SELECT "users".* FROM "users" INNER JOIN "jobs_users" ON "users"."id" = "jobs_users"."user_id" WHERE "jobs_users"."job_id" = $1 [["job_id", 3948]]
Dec 27 14:32:48 enigmatic-temple-38800 app/web.1: D, [2018-12-27T22:32:48.154318 #4] DEBUG -- : [f80358c4-cf90-4004-86c0-4389c9fbc264] User Load (2.0ms) SELECT "users".* FROM "users" INNER JOIN "jobs_users" ON "users"."id" = "jobs_users"."user_id" WHERE "jobs_users"."job_id" = $1 [["job_id", 3947]]
Dec 27 14:32:48 enigmatic-temple-38800 app/web.1: D, [2018-12-27T22:32:48.159597 #4] DEBUG -- : [f80358c4-cf90-4004-86c0-4389c9fbc264] User Load (2.1ms) SELECT "users".* FROM "users" INNER JOIN "jobs_users" ON "users"."id" = "jobs_users"."user_id" WHERE "jobs_users"."job_id" = $1 [["job_id", 3754]]
Dec 27 14:32:48 enigmatic-temple-38800 app/web.1: D, [2018-12-27T22:32:48.164560 #4] DEBUG -- : [f80358c4-cf90-4004-86c0-4389c9fbc264] User Load (1.9ms) SELECT "users".* FROM "users" INNER JOIN "jobs_users" ON "users"."id" = "jobs_users"."user_id" WHERE "jobs_users"."job_id" = $1 [["job_id", 4486]]
Dec 27 14:32:48 enigmatic-temple-38800 app/web.1: D, [2018-12-27T22:32:48.171196 #4] DEBUG -- : [f80358c4-cf90-4004-86c0-4389c9fbc264] User Load (3.5ms) SELECT "users".* FROM "users" INNER JOIN "jobs_users" ON "users"."id" = "jobs_users"."user_id" WHERE "jobs_users"."job_id" = $1 [["job_id", 4498]]
Dec 27 14:32:48 enigmatic-temple-38800 app/web.1: D, [2018-12-27T22:32:48.176346 #4] DEBUG -- : [f80358c4-cf90-4004-86c0-4389c9fbc264] (2.2ms) SELECT COUNT(*) FROM "jobs" WHERE "jobs"."location_id" = $1 AND "jobs"."complete" = $2 [["location_id", 3], ["complete", "f"]]
Dec 27 14:32:48 enigmatic-temple-38800 app/web.1: I, [2018-12-27T22:32:48.181498 #4] INFO -- : [f80358c4-cf90-4004-86c0-4389c9fbc264] Rendered jobs/list.html.erb within layouts/application (169.6ms)
Dec 27 14:32:48 enigmatic-temple-38800 app/web.1: D, [2018-12-27T22:32:48.186723 #4] DEBUG -- : [f80358c4-cf90-4004-86c0-4389c9fbc264] CACHE Location Load (0.0ms) SELECT "locations".* FROM "locations" INNER JOIN "locations_users" ON "locations"."id" = "locations_users"."location_id" WHERE "locations_users"."user_id" = $1 AND "locations"."id" = $2 LIMIT $3 [["user_id", 9], ["id", 3], ["LIMIT", 1]]
Dec 27 14:32:48 enigmatic-temple-38800 app/web.1: D, [2018-12-27T22:32:48.190361 #4] DEBUG -- : [f80358c4-cf90-4004-86c0-4389c9fbc264] Location Load (1.3ms) SELECT "locations".* FROM "locations" INNER JOIN "locations_users" ON "locations"."id" = "locations_users"."location_id" WHERE "locations_users"."user_id" = $1 [["user_id", 9]]
Dec 27 14:32:48 enigmatic-temple-38800 app/web.1: D, [2018-12-27T22:32:48.193899 #4] DEBUG -- : [f80358c4-cf90-4004-86c0-4389c9fbc264] Account Load (1.3ms) SELECT "accounts".* FROM "accounts" WHERE "accounts"."id" = $1 LIMIT $2 [["id", 2], ["LIMIT", 1]]
Dec 27 14:32:48 enigmatic-temple-38800 app/web.1: D, [2018-12-27T22:32:48.197861 #4] DEBUG -- : [f80358c4-cf90-4004-86c0-4389c9fbc264] (1.5ms) SELECT COUNT(*) FROM "notifications" WHERE "notifications"."notifiable_id" = $1 AND "notifications"."notifiable_type" = $2 [["notifiable_id", 2], ["notifiable_type", "Account"]]
Dec 27 14:32:48 enigmatic-temple-38800 app/web.1: I, [2018-12-27T22:32:48.199790 #4] INFO -- : [f80358c4-cf90-4004-86c0-4389c9fbc264] Rendered layouts/_nav.html.erb (16.5ms)
Dec 27 14:32:48 enigmatic-temple-38800 app/web.1: I, [2018-12-27T22:32:48.200925 #4] INFO -- : [f80358c4-cf90-4004-86c0-4389c9fbc264] Rendered layouts/_flash_messages.html.erb (0.1ms)
Dec 27 14:32:48 enigmatic-temple-38800 app/web.1: I, [2018-12-27T22:32:48.201976 #4] INFO -- : [f80358c4-cf90-4004-86c0-4389c9fbc264] Completed 200 OK in 66135ms (Views: 128.1ms | ActiveRecord: 65933.7ms | Solr: 0.0ms)