def _get_timeout_ms(timeout, payload_size):
    """Conservatively assume minimum 5 seconds or 3 seconds per 1MB."""
    if timeout is not None:
        return int(1000 * timeout)

    return int(1000 * max(3 * payload_size / 1024 / 1024, 5))