Guest User

Untitled

a guest
Mar 24th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.06 KB | None | 0 0
  1. # Testing the PHP driver with Atlas failovers
  2.  
  3. ## Ping
  4.  
  5. The following was added to the URI for an Atlas 3.6 cluster and assigned to a `$uri` variable in the PHP script:
  6.  
  7. ```
  8. ?serverSelectionTryOnce=false&serverSelectionTimeoutMS=15000
  9. ```
  10.  
  11. The script was then executed:
  12.  
  13. ```
  14. php atlas-ping.php
  15. ```
  16.  
  17. While the script was executing, a failover test was initiated from the Atlas cluster overview page.
  18.  
  19. Abridged output follows:
  20.  
  21. ```
  22. Success since 15:10:46.413856
  23. Number of commands: 5000
  24. Command durations: min=0.006383, max=0.028371, avg=0.007208 (seconds)
  25. Total duration: 36.067752 (seconds)
  26. Success since 15:11:22.482895
  27. Number of commands: 3813
  28. Command durations: min=0.006388, max=0.028537, avg=0.006798 (seconds)
  29. Total duration: 25.943891 (seconds)
  30. Failure since 15:11:48.428574
  31. Number of commands: 1
  32. Command durations: min=0.000799, max=0.000799, avg=0.000799 (seconds)
  33. Total duration: 0.000799 (seconds)
  34. Success since 15:12:00.379337
  35. Number of commands: 5000
  36. Command durations: min=0.006559, max=11.950593, avg=0.009302 (seconds)
  37. Total duration: 46.536481 (seconds)
  38. Success since 15:12:34.966290
  39. ^C
  40. ```
  41.  
  42. With this test, we see 8813 successful ping commands, followed by one failure. This failure occurs after the
  43. PHP library selects what it believes is a primary server for the ping operation, writes the command to the
  44. socket, and encounters an error because the connection has closed. The subsequent ping operation is delayed
  45. as it spends 11.95 seconds in the server selection loop attempting to find a new primary server. Thereafter,
  46. we see ping commands execute as quickly as before the failover.
  47.  
  48. This is roughly the same behavior we might expect for a write operation without retryable writes enabled.
  49.  
  50. ## Upsert with Retryable Writes
  51.  
  52. The following was added to the URI for an Atlas 3.6 cluster and assigned to a `$uri` variable in the PHP script:
  53.  
  54. ```
  55. ?serverSelectionTryOnce=false&serverSelectionTimeoutMS=15000&retryWrites=true
  56. ```
  57.  
  58. The script was then executed:
  59.  
  60. ```
  61. php atlas-upsert.php
  62. ```
  63.  
  64. While the script was executing, a failover test was initiated from the Atlas cluster overview page.
  65.  
  66. Abridged output follows:
  67.  
  68. ```
  69. Success since 15:20:09.754595
  70. Number of commands: 5000
  71. Command durations: min=0.006609, max=0.214565, avg=0.007060 (seconds)
  72. Total duration: 35.330071 (seconds)
  73. Success since 15:20:45.085878
  74. Number of commands: 5000
  75. Command durations: min=0.006436, max=11.581084, avg=0.009280 (seconds)
  76. Total duration: 46.427248 (seconds)
  77. Success since 15:21:31.514379
  78. Number of commands: 5000
  79. Command durations: min=0.006445, max=0.020294, avg=0.006885 (seconds)
  80. Total duration: 34.452975 (seconds)
  81. Success since 15:22:05.968087
  82. ^C
  83. ```
  84.  
  85. The failover kicked in during the second block of commands. The maximum command duration for that block is
  86. 11.58 seconds and is what we would expect for the retried write operation. The operation initially fails
  87. against a recently stepped down primary, the driver enters a server selection loop for up to 15 seconds,
  88. and finally retries the operation on the newly discovered primary. That sequence of events takes 11.58
  89. seconds.
Add Comment
Please, Sign In to add comment