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

  • Published on
    15-Aug-2015

  • View
    195

  • Download
    9

Embed Size (px)

Transcript

<ol><li> 1. RAILS- </li><li> 2. @goganchic ruby/erlang/nodejs </li><li> 3. </li><li> 4. </li><li> 5. </li><li> 6. </li><li> 7. - , - Unit- </li><li> 8. , </li><li> 9. (CPU/RAM/HDD) Zabbix PulseMeter (DB, Redis, API) Zabbix+ </li><li> 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 </li><li> 11. PULSEMETER https://github.com/savonarola/pulse-meter </li><li> 12. , </li><li> 13. </li><li> 14. Processing GET "/requests/10" for 1.1.1.1 Completed 200 OK in 336ms (Views: 0.8ms | ActiveRecord: 12.9ms) </li><li> 15. - </li><li> 16. Processing GET "/requests/10" for 1.1.1.1 Completed 200 OK in 336ms (Views: 0.8ms | ActiveRecord: 12.9ms) ? ? API ? ? </li><li> 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 ) </li><li> 18. + </li><li> 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)} </li><li> 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)} </li><li> 21. (.. ) </li><li> 22. </li><li> 23. </li><li> 24. SEGMENTATION FAULTS SEGMENTATION FAULTS EVERYWHERE! </li><li> 25. </li><li> 26. HTTP Rails- </li><li> 27. </li><li> 28. - bundle outdated - </li><li> 29. strace netstat ps htop tcpdump .. </li><li> 30. ! , , </li><li> 31. </li><li> 32. - 5 API </li><li> 33. - Ruby 2.1 Rails 4.1 Unicorn PostgreSQL PostGIS Resque Sidekiq </li><li> 34. ? RGeo::Error::ParseError: Not enough bytes left to fulfill 1 byte , . </li><li> 35. lib/coords.rb @@parser = RGeo::WKRep::WKBParser.new def coords @@parser.parse(geo_coords) end </li><li> 36. : WKBPARSER WKBParser instance- </li><li> 37. </li><li> 38. ? 502 </li><li> 39. CPU RAM - </li><li> 40. 1 : strace API API 85% : API </li><li> 41. </li><li> 42. ? 502 </li><li> 43. </li><li> 44. 2 : sidekiq : , . </li><li> 45. </li><li> 46. ? 502 </li><li> 47. CPU RAM . </li><li> 48. 2 ! </li><li> 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 </li><li> 50. BEGIN TRANSACTION; UPDATE ...; COMMIT; </li><li> 51. ! </li><li> 52. PFF </li><li> 53. 3 pg 0.14.1 (2012 ) </li><li> 54. 3 . pg ! </li><li> 55. - + . , , . </li><li> 56. ? </li></ol>