1# -*- coding: utf-8 -*- 2# Copyright 2015 Google Inc. All Rights Reserved. 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15"""Additional help text for throttling gsutil.""" 16 17from __future__ import absolute_import 18 19from gslib.help_provider import HelpProvider 20 21_DETAILED_HELP_TEXT = (""" 22<B>OVERVIEW</B> 23 Particularly when used with the -m (multi-threading) option, gsutil can 24 consume a significant amount of network bandwidth. In some cases this can 25 cause problems, for example if you start a large rsync operation over a 26 network link that's also used by a number of other important jobs. 27 28 While gsutil has no built-in support for throttling requests, there are 29 various tools available on Linux and MacOS that can be used to throttle 30 gsutil requests. 31 32 One tool is `trickle<http://monkey.org/~marius/pages/?page=trickle>`_ 33 (available via apt-get on Ubuntu systems), which will let you limit how much 34 bandwidth gsutil consumes. For example, the following command would limit 35 upload and download bandwidth consumed by gsutil rsync to 100 KBps: 36 37 trickle -d 100 -u 100 gsutil -m rsync -r ./dir gs://some bucket 38 39 Another tool is 40 `ionice<http://www.tutorialspoint.com/unix_commands/ionice.htm>`_ (built 41 in to many Linux systems), which will let you limit how much I/O capacity 42 gsutil consumes (e.g., to avoid letting it monopolize your local disk). For 43 example, the following command would reduce I/O priority of gsutil so it 44 doesn't monopolize your local disk: 45 46 ionice -c 2 -n 7 gsutil -m rsync -r ./dir gs://some bucket 47""") 48 49 50class CommandOptions(HelpProvider): 51 """Additional help text for throttling gsutil.""" 52 53 # Help specification. See help_provider.py for documentation. 54 help_spec = HelpProvider.HelpSpec( 55 help_name='throttling', 56 help_name_aliases=['bandwidth', 'limit', 'nice'], 57 help_type='additional_help', 58 help_one_line_summary='Throttling gsutil', 59 help_text=_DETAILED_HELP_TEXT, 60 subcommand_help_text={}, 61 ) 62