/testing/profiling/engine/README.md

https://github.com/SeldonIO/seldon-core · Markdown · 143 lines · 125 code · 18 blank · 0 comment · 0 complexity · d0fc588354d0941cbf086deb0d657f78 MD5 · raw file

  1. # Profiling/Debugging Service Orchestrator
  2. # YourKit Profiler
  3. 1. Create debug image using Makefile. Ensure you use current version of engine.
  4. 1. Launch Seldon Core with this image as the engine image using, e.g.
  5. ```
  6. !helm install ../helm-charts/seldon-core --name seldon-core --namespace seldon --set ambassador.enabled=true --set engine.image.name=seldonio/engine-debug:0.2.6-SNAPSHOT
  7. ```
  8. 1. Check logs of instance to get port and port forward to it, e.g.
  9. ```
  10. kubectl port-forward mymodel-mymodel-7cd068f-54b4bfd4b5-njkrq -n seldon 10001:10001
  11. ```
  12. 1. Attach to JVM using [YourKit Java Profiler](https://www.ej-technologies.com/products/jprofiler/overview.html).
  13. # JVisualVM
  14. 1. Port forward to debug port which is added as default JAVA OPTS, e.g.
  15. ```
  16. kubectl port-forward mnist-classifier-mnist-classifier-svc-orch-5c49b566d7-bz7bl -n seldon 9090:9090
  17. ```
  18. 1. Run [visualvm](https://visualvm.github.io/) and attach to process in list
  19. # Remote Interactive Debug
  20. 1. Annotate Seldon Deployment with ```"seldon.io/engine-java-opts" : "-agentlib:jdwp=transport=dt_socket,address=9090,server=y,suspend=n"```
  21. 1. Apply SeldonDeployment
  22. 1. Port forward the port used above
  23. 1. From Eclipse create Remote Debug session using 127.0.0.1 and port above.
  24. Example deployment:
  25. ```
  26. {
  27. "apiVersion": "machinelearning.seldon.io/v1alpha2",
  28. "kind": "SeldonDeployment",
  29. "metadata": {
  30. "labels": {
  31. "app": "seldon"
  32. },
  33. "name": "seldon-model"
  34. },
  35. "spec": {
  36. "name": "test-deployment",
  37. "oauth_key": "oauth-key",
  38. "oauth_secret": "oauth-secret",
  39. "predictors": [
  40. {
  41. "componentSpecs": [{
  42. "spec": {
  43. "containers": [
  44. {
  45. "image": "seldonio/mock_classifier:1.0",
  46. "imagePullPolicy": "IfNotPresent",
  47. "name": "classifier",
  48. "resources": {
  49. "requests": {
  50. "memory": "1Mi"
  51. }
  52. }
  53. }
  54. ],
  55. "terminationGracePeriodSeconds": 1
  56. }
  57. }],
  58. "graph": {
  59. "children": [],
  60. "name": "classifier",
  61. "endpoint": {
  62. "type" : "REST"
  63. },
  64. "type": "MODEL"
  65. },
  66. "name": "example",
  67. "replicas": 1,
  68. "labels": {
  69. "version" : "v1"
  70. },
  71. "annotations" : { "seldon.io/engine-java-opts" : "-agentlib:jdwp=transport=dt_socket,address=9090,server=y,suspend=n" }
  72. }
  73. ]
  74. }
  75. }
  76. ```
  77. # Local Interactive Debug
  78. 1. Change ```engine/deploymentdef.json``` as needed. This is default Seldon Deployment that will be run.
  79. 1. Run Engine in Eclipse and debug
  80. To Run with local Model, for example:
  81. Use mean_classifier from examples and run locally:
  82. ```
  83. PREDICTIVE_UNIT_SERVICE_PORT=5001 seldon-core-microservice MeanClassifier REST --service-type MODEL
  84. ```
  85. Change ```engine/deploymentdef.json``` to:
  86. ```
  87. {
  88. "componentSpecs": [{
  89. "spec": {
  90. "containers": [
  91. {
  92. "image": "seldonio/mock_classifier_rest:1.0",
  93. "imagePullPolicy": "IfNotPresent",
  94. "name": "classifier",
  95. "resources": {
  96. "requests": {
  97. "memory": "1Mi"
  98. }
  99. }
  100. }
  101. ],
  102. "terminationGracePeriodSeconds": 1
  103. }
  104. }],
  105. "graph": {
  106. "children": [],
  107. "name": "classifier",
  108. "endpoint": {
  109. "type" : "REST",
  110. "service_host" : "0.0.0.0",
  111. "service_port" : 5001
  112. },
  113. "type": "MODEL"
  114. },
  115. "name": "example",
  116. "replicas": 1,
  117. "labels": {
  118. "version" : "v1"
  119. }
  120. }
  121. ```
  122. Send requests:
  123. ```
  124. curl 0.0.0.0:8081/api/v0.1/predictions -d '{"data":{"names":["a","b"],"ndarray":[[1,2]]}}}' -H "Content-Type: application/json"
  125. ```