Отладка и эксплуатация Rails-приложений

Embed Size (px)

Text of Отладка и эксплуатация Rails-приложений

  1. 1. RAILS-
  2. 2. @goganchic ruby/erlang/nodejs
  3. 3.
  4. 4.
  5. 5.
  6. 6.
  7. 7. - , - Unit-
  8. 8. ,
  9. 9. (CPU/RAM/HDD) Zabbix PulseMeter (DB, Redis, API) Zabbix+
  10. 10. PULSEMETER sensors = PulseMeter::Sensor::Configuration.new( root_webpage_requests_per_5_minutes: { sensor_type: 'timelined/counter', args: {interval: 5.minutes, ttl: 1.week} } ) PulseMeter::Observer.observe_method(HomeController, :index, sensors) do root_webpage_requests_per_5_minutes(1) end
  11. 11. PULSEMETER https://github.com/savonarola/pulse-meter
  12. 12. ,
  13. 13.
  14. 14. Processing GET "/requests/10" for 1.1.1.1 Completed 200 OK in 336ms (Views: 0.8ms | ActiveRecord: 12.9ms)
  15. 15. -
  16. 16. Processing GET "/requests/10" for 1.1.1.1 Completed 200 OK in 336ms (Views: 0.8ms | ActiveRecord: 12.9ms) ? ? API ? ?
  17. 17. [2015-04-18 20:11:39] [7d1fe7a2] [user_id=42] Processing GET "/requests/10" for 1.1.1.1 [2015-04-18 20:11:39] [7d1fe7a2] [user_id=42] PartnerApi request: http://example.com/?param=value [2015-04-18 20:11:39] [7d1fe7a2] [user_id=42] PartnerApi response: 403 Forbidden [2015-04-18 20:11:39] [7d1fe7a2] Completed 200 OK in 336ms (Views: 0.8ms | ActiveRecord: 12.9ms) + (logstash )
  18. 18. +
  19. 19. def process_request(params) resp = HttpRequest.perform(params_for(request)) data = ResponseParser.parse(resp) DataProcessor.process(data) end requests.each {|r| process_request(r)}
  20. 20. def process_request(request) AsyncHttpRequest.perform(params_for(request)) do |resp| AsyncResponseParser.parse(resp) do |data| AsyncDataProcessor.process(data) end end end requests.each {|r| process_request(r)}
  21. 21. (.. )
  22. 22.
  23. 23.
  24. 24. SEGMENTATION FAULTS SEGMENTATION FAULTS EVERYWHERE!
  25. 25.
  26. 26. HTTP Rails-
  27. 27.
  28. 28. - bundle outdated -
  29. 29. strace netstat ps htop tcpdump ..
  30. 30. ! , ,
  31. 31.
  32. 32. - 5 API
  33. 33. - Ruby 2.1 Rails 4.1 Unicorn PostgreSQL PostGIS Resque Sidekiq
  34. 34. ? RGeo::Error::ParseError: Not enough bytes left to fulfill 1 byte , .
  35. 35. lib/coords.rb @@parser = RGeo::WKRep::WKBParser.new def coords @@parser.parse(geo_coords) end
  36. 36. : WKBPARSER WKBParser instance-
  37. 37.
  38. 38. ? 502
  39. 39. CPU RAM -
  40. 40. 1 : strace API API 85% : API
  41. 41.
  42. 42. ? 502
  43. 43.
  44. 44. 2 : sidekiq : , .
  45. 45.
  46. 46. ? 502
  47. 47. CPU RAM .
  48. 48. 2 !
  49. 49. def fill_location(loc) if loc self.coords_source = loc.source self.coords = loc.coords fill_address_if_required end self.state = 'processed' save! # end
  50. 50. BEGIN TRANSACTION; UPDATE ...; COMMIT;
  51. 51. !
  52. 52. PFF
  53. 53. 3 pg 0.14.1 (2012 )
  54. 54. 3 . pg !
  55. 55. - + . , , .
  56. 56. ?