/mautic/vendor/rackspace/php-opencloud/doc/services/object-store/migrating-containers.rst

https://gitlab.com/randydanniswara/website · ReStructuredText · 111 lines · 71 code · 40 blank · 0 comment · 0 complexity · 1a3ad79c80c3f5c0cc3dd716555b53a0 MD5 · raw file

  1. Migrating containers across regions
  2. ===================================
  3. Currently, there exists no single API operation to copy containers
  4. across geographic endpoints. Although the API offers a ``COPY``
  5. operation for individual files, this does not work for cross-region
  6. copying. The SDK, however, does offer this functionality.
  7. You **will** be charged for bandwidth between regions, so it's advisable
  8. to use ServiceNet where possible (which is free).
  9. Requirements
  10. ------------
  11. - You must install the full Guzzle package, so that the process can
  12. take advantage of Guzzle's batching functionality (it allows parallel
  13. requests to be batched for greater efficiency). You can do this by
  14. running:
  15. .. code-block:: bash
  16. composer require guzzle/guzzle
  17. - Depending on the size and number of transfer items, you will need to
  18. raise PHP's memory limit:
  19. .. code-block:: php
  20. ini_set('memory_limit', '512M');
  21. - You will need to enact some kind of backoff/retry strategy for rate
  22. limits. Guzzle comes with a convenient feature that just needs to be
  23. added as a normal subscriber:
  24. .. code-block:: php
  25. use Guzzle\Plugin\Backoff\BackoffPlugin;
  26. // set timeout in secs
  27. $timeout = 10;
  28. // set HTTP error codes
  29. $httpErrors = array(500, 503, 408);
  30. $backoffPlugin = BackoffPlugin::getExponentialBackoff($timeout, $httpErrors);
  31. $client->addSubscriber($backoffPlugin);
  32. This tells the client to retry up to ``10`` times for failed requests
  33. have resulted in these HTTP status codes: ``500``, ``503`` or ``408``.
  34. Setup
  35. -----
  36. You can access all this functionality by executing:
  37. .. code-block:: php
  38. $ordService = $client->objectStoreService('cloudFiles', 'ORD');
  39. $iadService = $client->objectStoreService('cloudFiles', 'IAD');
  40. $oldContainer = $ordService->getContainer('old_container');
  41. $newContainer = $iadService->getContainer('new_container');
  42. $iadService->migrateContainer($oldContainer, $newContainer);
  43. It's advisable to do this process in a Cloud Server in one of the two
  44. regions you're migrating to/from. This allows you to use ``privateURL``
  45. as the third argument in the ``objectStoreService`` methods like this:
  46. .. code-block:: php
  47. $client->objectStoreService('cloudFiles', 'IAD', 'privateURL');
  48. This will ensure that traffic between your server and your new IAD
  49. container will be held over the internal Rackspace network which is
  50. free.
  51. Options
  52. -------
  53. You can pass in an array of arguments to the method:
  54. .. code-block:: php
  55. $options = array(
  56. 'read.batchLimit' => 100,
  57. 'read.pageLimit' => 100,
  58. 'write.batchLimit' => 50
  59. );
  60. $iadService->migrateContainer($oldContainer, $newContainer, $options);
  61. Options explained
  62. ~~~~~~~~~~~~~~~~~
  63. +------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------+
  64. | Name | Description | Default |
  65. +========================+===============================================================================================================================================================================================================================================================================================================================================+===========+
  66. | ``read.pageLimit`` | When the process begins, it has to collect all the files that exist in the old container. It does this through a conventional ``objectList`` method, which calls the ``PaginatedIterator``. This iterator has the option to specify the page size for the collection (i.e. how many items are contained per page in responses from the API) | 10,000 |
  67. +------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------+
  68. | ``read.batchLimit`` | After the data objects are collected, the process needs to send an individual GET request to ascertain more information. In order to make this process faster, these individual GET requests are batched together and sent in parallel. This limit refers to how many of these GET requests are batched together. | 1,000 |
  69. +------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------+
  70. | ``write.batchLimit`` | Once each file has been retrieved from the API, a PUT request is executed against the new container. Similar to above, these PUT requests are batched - and this number refers to the amount of PUT requests batched together. | 100 |
  71. +------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------+