File: generator.en.rst

package info (click to toggle)
trafficserver 9.2.5%2Bds-0%2Bdeb12u3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 64,964 kB
  • sloc: cpp: 345,958; ansic: 31,184; python: 25,297; sh: 7,023; makefile: 3,045; perl: 2,255; java: 277; pascal: 119; sql: 94; xml: 2
file content (86 lines) | stat: -rw-r--r-- 4,085 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
.. _admin-plugins-generator:

Generator Plugin
****************

.. Licensed to the Apache Software Foundation (ASF) under one
   or more contributor license agreements.  See the NOTICE file
  distributed with this work for additional information
  regarding copyright ownership.  The ASF licenses this file
  to you under the Apache License, Version 2.0 (the
  "License"); you may not use this file except in compliance
  with the License.  You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an
  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  KIND, either express or implied.  See the License for the
  specific language governing permissions and limitations
  under the License.

The `Generator` allows testing of synthetic workloads by generating
HTTP responses of various sizes and receiving POST bodies. The size
and cacheability of the response is specified by the first two components
of the requested URL path. This plugin supports the ``GET``, ``HEAD``,
and ``POST`` HTTP methods.

+---------------+----------------------------------------------------------------+
|Path component | Description                                                    |
+===============+================================================================+
|1              | ``cache`` or ``nocache``. If ``cache`` is specified, the       |
|               | `Generator` plugin will respond with ``Cache-Control`` headers |
|               | marking the response as cacheable.                             |
+---------------+----------------------------------------------------------------+
|2              | Integral number of bytes to return in the response.            |
+---------------+----------------------------------------------------------------+

Path components after the first 2 are ignored. This means that the
trailing path components can be manipulated to create unique URLs
following any convenient convention.

The `Generator` plugin inspects the following HTTP client request headers:

+-----------------------+--------------------------------------------------------+
|Header                 | Description                                            |
+=======================+========================================================+
| ``Generator-Delay``   | The number of milliseconds to wait before sending a    |
|                       | response. The default is to not wait.                  |
+-----------------------+--------------------------------------------------------+
| ``Generator-MaxAge``  | The number of seconds that a response should be cached |
|                       | for. This is used in the ``max-age`` field of the      |
|                       | response's ``Cache-Control`` header.                   |
+-----------------------+--------------------------------------------------------+

The `Generator` plugin publishes the following metrics:

  generator.response_bytes:
    The total number of bytes emitted
  generator.response_count:
    The number of HTTP responses generated by the plugin

Examples:
---------

The most common way to use the `Generator` plugin is to configure
it as a remap plugin in :file:`remap.config`::

  map http://workload.example.com/ http://127.0.0.1/ \
    @plugin=generator.so

Notice that although the remap target is never contacted because
the `Generator` plugin intercepts the request and acts as the origin
server, it must be syntactically valid and resolvable in DNS.

A 10 byte, cacheable object can then be generated::

  $ curl -o /dev/null -x 127.0.0.1:8080 http://workload.example.com/cache/10/caf1fc92332b3a3c8cb8b3826b6a1658

The `Generator` plugin can return responses as large as you like::

  $ curl -o /dev/null -x 127.0.0.1:8080 http://workload.example.com/cache/$((10 * 1024 * 1024))/$RANDOM

The `Generator` plugin can also receive POST requests::

  $ curl -o /dev/null -x 127.0.0.1:8080 -d @/etc/hosts http://workload.example.com/