Setting a per-user limit

GeoServer usually serves data to several users. According to the size of your organization, the actual number may range from a few to several hundred concurrent requests.

As with any other shared resource, we will ensure that none can exceed a certain amount of processing power, leaving others waiting for what remains.

This is handled by the control flow module, which uses a per user limit setting. We will implement it in this recipe.

How to do it…

  1. Using your favorite text editor, open the previously created controlflow.properties file and modify its contents as follows:
    #ip.blacklist=127.0.0.10
    # Maximum number of concurrent requests per user
    user=2
  2. Now save the file and close it.
  3. Open your browser and point it to the GeoServer Layer preview page.
  4. Click on the OpenLayers preview for the NaturalEarth:blueMarble layer. A new tab will open with the usual simple app to browse the data.
  5. Now, open the Firebug console and switch to the Net panel. Click on the Activate firebug for the current website button. An empty list of requests will be shown in the window, as shown in the following screenshot:
    How to do it…

    Tip

    In the preceding steps, we use Firefox and its debug extension Firebug. Firebug is not available by default in the browser but you can easily add it from the add-in page.

    If you are more comfortable with Chrome, you may follow the instructions using the Developers tools' console; it opens when you press Ctrl + Shift + I.

  6. In the OpenLayers preview page for NaturalEarth:blueMarble, open the options toolbar, and from the Tiling combo, select the Tiled option, as shown in the following screenshot:
    How to do it…
  7. Now, when you switch to the Firebug console window, you should see a few concurrent requests sent to GeoServer, as shown in the following screenshot:
    How to do it…

How it works…

In the previous steps, you set a limit of two concurrent requests per user. This is a very small number and you may want to increase it during a production installation.

When calculating the proper number to insert, you have to consider not only the GeoServer capacity to stand against user requests, but also if your users use a web application, consider that browser's limit by default as the concurrent requests you may send to the same host.

Note

With Firefox, you may check its limit and also change it by opening the about:config URL and searching for the network.http.max-persistent-connections-per-server parameter (defaulting to six limits for the current release).

To check how this works, you open the layer preview page. The simple OpenLayers application contained sends a GetMap request to GeoServer, but a single request will not trigger the limit. So how can you test whether it is really working?

Using the Tiled mode does the magic! Of course, when selecting it, the application, instead of sending a single request upon your map actions, sends requests for tiles that compose your map. It uses a regular tessellation and you can check it by having a look at the parameters for each GetMap request.

Using Firebug, inspect the details for the requests sent; you can control all GetMap requests to have a 256 x 256 size as follows:

How it works…

Using tiles lets you produce many concurrent requests, as shown in one of the earlier screenshots.

To check how GeoServer handles them and to be sure that the control flow module is properly working, open the log file. You should see something similar to the following:

2014-06-16 17:28:01,902 DEBUG [org.geoserver.ows] - Getting layers and styles from LAYERS and STYLES
2014-06-16 17:28:01,902 DEBUG [org.geoserver.ows] - establishing raster style for NaturalEarth:blueMarble
2014-06-16 17:28:01,902 DEBUG [org.geoserver.ows] - Getting layers and styles from LAYERS and STYLES
2014-06-16 17:28:01,902 DEBUG [org.geoserver.ows] - establishing raster style for NaturalEarth:blueMarble
2014-06-16 17:28:01,902 DEBUG [org.geoserver.flow] - UserFlowController(4,GS_CFLOW_-2cd39e64:146a546eaa8:-8000) queue size 2
2014-06-16 17:28:01,902 DEBUG [org.geoserver.flow] - UserFlowController(4,GS_CFLOW_-2cd39e64:146a546eaa8:-8000) queue size 2
2014-06-16 17:28:01,902 DEBUG [org.geoserver.flow] - UserFlowController(4,GS_CFLOW_-2cd39e64:146a546eaa8:-8000) total queues 1
2014-06-16 17:28:01,902 DEBUG [org.geoserver.flow] - UserFlowController(4,GS_CFLOW_-2cd39e64:146a546eaa8:-8000) total queues 1
2014-06-16 17:28:01,902 DEBUG [org.geoserver.flow] - UserFlowController(4) purged 0 stale queues

As you can see, the module properly handles your requests, queuing them, and avoiding your GeoServer instance from getting overwhelmed by too many concurrent requests.

Note

GeoServer logging has several profiles. To find information about the control flow module processing requests, select the GEOSERVER_DEVELOPER_LOGGING profile.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.206.254