improving document

This commit is contained in:
Julien Neuhart
2019-09-30 17:16:40 +02:00
parent 8f721cd12a
commit 9968a816db
14 changed files with 78 additions and 111 deletions

View File

@@ -6,7 +6,5 @@ title: Introduction
* HTML and Markdown conversions using Google Chrome headless
* Office conversions (.txt, .rtf, .docx, .doc, .odt, .pptx, .ppt, .odp and so on) using [unoconv](https://github.com/dagwieers/unoconv)
* Performance: Google Chrome and LibreOffice started once in the background thanks to PM2
* Failure prevention: PM2 automatically restarts previous processes if they fail
* Assets: send your header, footer, images, fonts, stylesheets and so on for converting your HTML and Markdown to beaufitul PDFs!
* Easily interact with the API using our [Go](https://github.com/thecodingmachine/gotenberg-go-client) and [PHP](https://github.com/thecodingmachine/gotenberg-php-client) libraries
* Easily interact with the API using our [Go](https://github.com/thecodingmachine/gotenberg-go-client) and [PHP](https://github.com/thecodingmachine/gotenberg-php-client) libraries

View File

@@ -36,7 +36,6 @@ services:
It may also be deployed with Kubernetes.
Make sure to provide enough memory and CPU requests (for instance `512Mi` and `0.2` CPU).
Otherwise the API will not be able to launch Google Chrome and LibreOffice (unoconv).
> The more resources are granted, the quicker will be the conversions.
@@ -49,4 +48,4 @@ securityContext:
```
In the following examples, we will assume your
Gotenberg API is available at [http://localhost:3000](http://localhost:3000).
Gotenberg API is available at [http://localhost:3000](http://localhost:3000).

View File

@@ -22,4 +22,4 @@ Then the PHP client:
```bash
$ composer require thecodingmachine/gotenberg-php-client
```
```

View File

@@ -6,13 +6,6 @@ Gotenberg provides the endpoint `/convert/html` for HTML conversions.
It accepts `POST` requests with a `multipart/form-data` Content-Type.
> **Attention:** currently, Google Chrome misbehaves if there are too many concurrent conversions.
> That's why for HTML, [URL](#url) and [Markdown](#markdown) conversions, the API does only 6 conversions at a time.
> The more concurrent requests, the more `504` HTTP codes the API will return.
>
> See the [scalability section](#scalability) to find how to mitigate this issue.
> You may also take a look at the [timeout section](#timeout).
## Basic
The only requirement is to send a file named `index.html`: it is the file

View File

@@ -6,13 +6,6 @@ Gotenberg provides the endpoint `/convert/office` for Office document conversion
It accepts `POST` requests with a `multipart/form-data` Content-Type.
> **Attention:** currently, `unoconv` cannot perform concurrent conversions.
> That's why for Office conversions, the API does only one conversion at a time.
> The more concurrent requests, the more `504` HTTP codes the API will return.
>
> See the [scalability section](#scalability) to find how to mitigate this issue.
> You may also take a look at the [timeout section](#timeout).
## Basic
You may send one or more Office documents. Following file extensions are accepted:

View File

@@ -52,4 +52,4 @@ $files = [
$request = new MergeRequest($files);
$dest = "result.pdf";
$client->store($request, $dest);
```
```

View File

@@ -50,4 +50,4 @@ $request = new HTMLRequest($index);
$request->setWaitTimeout(2.5);
$dest = "result.pdf";
$client->store($request, $dest);
```
```

View File

@@ -98,4 +98,4 @@ $request = new HTMLRequest($index);
$request->setWebhookURL('http://myapp.com/webhook/');
$request->setWebhookURLTimeout(2.5);
$resp = $client->post($request);
```
```

View File

@@ -47,4 +47,4 @@ $index = DocumentFactory::makeFromPath('index.html', 'index.html');
$request = new HTMLRequest($index);
$request->setResultFilename('foo.pdf');
$resp = $client->post($request);
```
```

View File

@@ -2,6 +2,31 @@
title: Scalability
---
Google Chrome and unoconv (LibreOffice) are intricate programs.
Gotenberg tries to abstract as much complexity as possible but it can
only do it to a certain extend.
For instance, Google Chrome misbehaves if there are too many concurrent conversions.
That's why for [HTML](#html), [URL](#url) and [Markdown](#markdown) conversions, the API does only 6 conversions in parallel.
The more concurrent requests, the more `504` HTTP codes the API will return.
On another hand, for [Office](#office) conversions, the API will start as many unoconv (LibreOffice) instances as there are
requests. The limitation here is the available memory.
## Strategies
### Increase timeout
This strategy is mostly for [HTML](#html), [URL](#url) and [Markdown](#markdown) conversions.
You may increase the conversion timeout. In other word, you accept that a conversion takes more time
if there are more than 6 conversions in parallel.
> See [timeout section](#timeout).
### Scaling
The API being stateless, you may scale it as much as you want.
For instance, using the following Docker Compose file:
@@ -24,4 +49,4 @@ $ docker-compose up --scale gotenberg=your_number_of_instances
```
When requesting the Gotenberg service with your client(s), Docker will automatically
redirect a request to a Gotenberg container according to the round-robin strategy.
redirect a request to a Gotenberg container according to the round-robin strategy.

View File

@@ -5,34 +5,8 @@ title: Ping
Gotenberg provides the endpoint `/ping` for checking the API availability with
a simple `GET` request.
If `LOG_LEVEL` is `"DEBUG"`, it also returns details about the PM2 processes in JSON format.
For instance:
Currently this endpoint does nothing special. A better way to monitor
Gotenberg would be by checking the memory usage.
```json
[
{
"name": "google-chrome-stable",
"pm2_env": {
"status": "online",
"restart_time": 0
},
"monit": {
"memory": 72294400,
"cpu": 0
}
},
{
"name": "unoconv",
"pm2_env": {
"status": "online",
"restart_time": 0
},
"monit": {
"memory": 71000064,
"cpu": 0
}
}
]
```
> if `LOG_LEVEL` is **not** `"DEBUG"`, no log entries are written.
Also, as Google Chrome and unoconv (LibreOffice) are intricate programs, you should
restart your Gotenberg instances from time to time to ensure a nominal behaviour.

View File

@@ -10,4 +10,4 @@ If you wish to use more fonts, you will have to create your own image:
FROM thecodingmachine/gotenberg:6
RUN apt-get -y install yourfonts
```
```

View File

@@ -5,4 +5,4 @@ title: Links
* Follow the progress on the [GitHub repository](https://github.com/thecodingmachine/gotenberg)
* Follow [@gulnap](https://twitter.com/gulnap) on Twitter
Psst: TheCodingMachine is always looking for [talented coders](https://coders.thecodingmachine.com).
Psst: TheCodingMachine is always looking for [talented coders](https://coders.thecodingmachine.com).