File: README.txt

package info (click to toggle)
trafficserver 9.2.5%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 53,008 kB
  • sloc: cpp: 345,484; ansic: 31,134; python: 24,200; sh: 7,271; makefile: 3,045; perl: 2,261; java: 277; pascal: 119; sql: 94; xml: 2
file content (132 lines) | stat: -rw-r--r-- 4,002 bytes parent folder | download | duplicates (4)
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132

	Thread pool sample plugin for SDK 3.0
	-------------------------------------

List of files:
==============
 Plugin
 ------
 - psi.c : proxy side include plugin
 - thread.h : thread pool header
 - thread.c : thread pool implementation

 Tools for testing
 -----------------
 - include/gen.c : utility to generate text files of various size
 - include/gen_inc.sh : script to generate include files for testing

 - test/SDKTest/psi_server.c : SDKTest server plugins to test psi
 - test/SDKTest/SDKtest_server.config : SDKTest config file


Description
===========
 The plugin looks for the specific header "X-Psi" in the OS HTTP response.
 If this header is found, and if the document is of type text/html,
 the plugin parses the response body to find include tags: "<--include=filename-->".

 When an include tag is found, the plugin substitutes it by the content
 of the file `filename`.

 Filename must be a simple filename. It can not contain a path (relative or absolute).

 Example:
 --------
 The OS sends the following HTTP response:
	HTTP/1.0 200 OK\r\n
	Content-Type: text/html\r\n
	X-Psi: true\r\n
	\r\n\r\n
	<HTML>
	My html source code
	<!--include=my_include.txt-->
	Some more html code
	</HTML>

 The text file 'include.txt' on the proxy filesystem contains:
	include content line 1
	include content line 2
	include content line 3

 The response processed by the proxy and finally sent to the client is:
	HTTP/1.0 200 OK\r\n
	Content-Type: text/html\r\n
	X-Psi: true\r\n
	\r\n\r\n
	<HTML>
	My html source code
	include content line 1
	include content line 2
	include content line 3
	Some more html code
	</HTML>
 Note that the content of the 'include.txt' file is now inserted into
 the body of the HTML response.


Architecture
============

 Pool of threads
 ---------------
 The psi plugin uses a pool of threads to make system blocking calls (access to disk).
 This is to avoid blocking a TS thread and slowing down the whole TS.

 High level algorithm:
 --------------------
 0. At init time, the plugin spawns threads.
 1. The plugin scans any HTTP response message header for the specific header X-Psi.
 2. If found, it sets up a transformation.
 3. The transformation parses the HTML content.
 4. When an include tag is found, the plugin creates a job and put it into
    the thread's queue of jobs.
 5. Then it goes into an inactive mode, waiting for the job to get done by a thread.
 6. A thread picks up the job. Reads the file from the disk (blocking system call).
    Then reenables the transformation.
 7. The transformation insert the content of the file into the HTML body.
 8. Go to step 8.



Plugin Installation
===================
 Add a line to Traffic Server plugin.config with the name of the plugin: psi.so
 No arguments required.

 The files to include must be located under the directory <plugin_path>/include
 <plugin_path> is the path where the psi.so library is located
 (by default $TS_HOME/etc/trafficserver/plugins)

 Start TS as usual. Now any HTTP response with the X-Psi headers will be processed
 by the PSI plugin.



Plugin Testing
==============

 Sample include file generation
 ------------------------------
 A basic utility ('gen')to generate files to be inserted is provided
 in the directory thread_pool/include.
 This create text files of various sizes.
 Compile gen the execute gen_inc.sh to generate files:
 > cd include
 > make
 > gen_inc.sh

 Load
 ----
 SDKTest can be used to test this plugin. SDKTest allows to simulate:
  - synthetic clients sending requests
  - a synthetic origin server

 The synthetic origin server has to be customized in order to send back
 responses that contains the specific 'X-Psi' header.
 This is done through a SDKTest server plugin.

 The rate of responses with X-Psi header is configurable thru a SDKTest config file.

 A SDKTest server plugin as well as a SDKTest configuration file
 are provided in the directory thread_pool/test/SDKTest.
 Refer to the SDKTest manual for detailed setup instructions.