> For the complete documentation index, see [llms.txt](https://documentation.alluxio.io/ee-ai-en/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://documentation.alluxio.io/ee-ai-en/ufs/bos.md).

# Baidu Object Storage

This guide describes how to configure [Baidu Object Storage (BOS)](https://cloud.baidu.com/doc/BOS/index.html) as Alluxio's under storage system. Baidu Object Storage (BOS) provides stable, secure, efficient and highly scalable storage services.

## Prerequisites

Before using BOS with Alluxio, follow the [BOS Process for Getting Started](https://intl.cloud.baidu.com/doc/BOS/s/Ik4xtp41n-en) to sign up for BOS and create a BOS bucket.

Before you get started, please ensure you have the required information listed below:

| `<BOS_BUCKET>`            | Create a new BOS bucket or use an existing bucket                                                                                                                                                                                                                                          |
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `<BOS_DIRECTORY>`         | The directory you want to use in the bucket, either by creating a new directory or using an existing one                                                                                                                                                                                   |
| `<BOS_ACCESS_KEY_ID>`     | <p>The <a href="https://intl.cloud.baidu.com/doc/Reference/s/jjwvz2e3p-en">Access Key ID</a> for BOS,<br>which are created and managed in the <a href="https://intl.cloud.baidu.com/doc/Reference/s/9jwvz2egb-en">BOS AccessKey management console</a></p>                                 |
| `<BOS_ACCESS_KEY_SECRET>` | <p>The <a href="https://intl.cloud.baidu.com/doc/Reference/s/jjwvz2e3p-en">Secret Access Key</a> for BOS,<br>which are created and managed in the <a href="https://intl.cloud.baidu.com/doc/Reference/s/9jwvz2egb-en">BOS AccessKey management console</a></p>                             |
| `<BOS_ENDPOINT>`          | <p>The internet endpoint of the bucket, which can be found in the bucket overview page with values like <code>bj.bcebos.com</code> and <code>gz.bcebos.com</code>.<br>Available endpoints are listed in the <a href="https://cloud.baidu.com/doc/BOS/s/akrqd2wcx">Region与Endpoint</a>.</p> |
| `<BOS_REGION>`            | <p>The region where the bucket is located, such as <code>cn-beijing</code> or <code>cn-guangzhou</code>.<br>Available regions are listed in the <a href="https://cloud.baidu.com/doc/BOS/s/akrqd2wcx">Region与Endpoint</a>.</p>                                                             |

## Basic Setup

For the general mount mechanism and `UnderFileSystem` CR field reference, see [Underlying Storage](https://documentation.alluxio.io/ee-ai-en/ufs.md#basic-mount-setup).

{% tabs %}
{% tab title="Kubernetes (Operator)" %}
An example `ufs.yaml` to create a BOS mount point with the operator:

```yaml
apiVersion: k8s-operator.alluxio.com/v1
kind: UnderFileSystem
metadata:
  name: alluxio-bos
  namespace: alx-ns
spec:
  alluxioCluster: alluxio-cluster
  path: bos://<BOS_BUCKET>/<BOS_DIRECTORY>
  mountPath: /bos
  mountOptions:
    fs.bos.accessKeyId: <BOS_ACCESS_KEY>
    fs.bos.accessKeySecret: <BOS_ACCESS_KEY_SECRET>
    fs.bos.endpoint: <BOS_ENDPOINT>
```

{% endtab %}

{% tab title="Docker / Bare-Metal" %}
An example command to mount `bos://<BOS_BUCKET>/<BOS_DIRECTORY>` to `/bos` if not using the operator:

```shell
bin/alluxio mount add --path /bos/ --ufs-uri bos://<BOS_BUCKET>/<BOS_DIRECTORY> \
  --option fs.bos.accessKeyId=<BOS_ACCESS_KEY> --option fs.bos.accessKeySecret=<BOS_ACCESS_KEY_SECRET> \
  --option fs.bos.endpoint=<BOS_ENDPOINT>
```

Note that if you want to mount the root of the BOS bucket, add a trailing slash after the bucket name (e.g. `bos://BOS_BUCKET/`).
{% endtab %}
{% endtabs %}

## Advanced Setup

Note that configuration options can be specified as mount options or as configuration properties in `conf/alluxio-site.properties`.\
The following sections will describe how to set configurations as properties, but they can also be set as mount options via `--option <key>=<value>`.

### HTTP and HTTPS

Alluxio uses HTTPS by default. The scheme in `fs.bos.endpoint` decides the protocol, and an endpoint without a scheme, including the default `bj.bcebos.com`, uses HTTPS. To use plain HTTP, write `http://` into the endpoint:

```properties
fs.bos.endpoint=http://<BOS_ENDPOINT>
```

`alluxio.underfs.bos.secure.http.enabled` is deprecated. Set to `false`, it still selects HTTP for an endpoint without a scheme and logs a warning.

### BOS multipart upload

We use multipart-upload method to upload one file by multiple parts, every part will be uploaded in one thread. It won't generate any temporary files while uploading.

There are other parameters you can specify in `conf/alluxio-site.properties` to potentially speed up the upload.

```properties
# Timeout for uploading part when using multipart upload.
alluxio.underfs.object.store.multipart.upload.timeout
```

```properties
# Thread pool size for BOS multipart upload.
alluxio.underfs.bos.multipart.upload.threads
```

```properties
# Multipart upload partition size for BOS. The default partition size is 16MB.
alluxio.underfs.bos.multipart.upload.part.size
```

Disable BOS multipart upload, the upload method uploads one file completely from start to end in one go. you need to modify `conf/alluxio-site.properties` to include:

```properties
alluxio.underfs.bos.multipart.upload.enabled=false
```

### Setting Request Retry Policy

For retry configuration that applies to all object store UFS types, see [Request Retry Policy](https://documentation.alluxio.io/ee-ai-en/ufs.md#request-retry-policy) in the UFS overview.

### High Concurrency Tuning

When integrating Alluxio with BOS, you can optimize performance by adjusting the following configurations:

* `alluxio.underfs.bos.connection.max`: Controls the max connection number with BOS. Default value is 1024.
* `alluxio.underfs.bos.io.threads.num`: Controls the IO thread with BOS. Default value is 256.
* `alluxio.underfs.bos.socket.timeout`: Controls the socket timeout with BOS. Default value is 50 seconds.
* `alluxio.underfs.bos.connect.timeout`： Controls the connection timeout with BOS. Default value is 50 seconds.
