[Geoserver-devel] Adding MBTiles Support in GWC

Hi all,
sorry for the cross posting.

We would like to add MBTiles support to GWC.
Follows a description of the work with the main issues\limitations.

I would like to have community feedback on this, by the way is there a better way to propose this work ?

* MBtiles and SQLitle *

MBtiles is a specification that describe how to store tiles in an SQLite database, this will allow us to store many tiles in a single SQLite
file avoiding us file systems headaches:
https://github.com/mapbox/mbtiles-spec/blob/master/1.1/spec.md.

We can rely on GeoTools gt-mbtiles module for reading and writing MBTiles, this way most of the work of implementing this blobstore will be
managing SQLite connections and SQLite files.

SQLite files cannot be managed as simple files. When connections to an SQLite database are open we should not delete, move or switch the
associated file. Databases files can be filled with "empty space" after deleting an huge amount of data or can become fragmented after
frequent inserts, updates or delete operations.

SQLite documentation warns us against putting databases files on a shared file system if multiple process need access to it (which is our
case). Unless we can rely on a distributed lock mechanism SQLite databases files should not be used with shared stores.

* VACUUM and DiskQuota *

To remove the fragmented space (or the empty space), the VACUUM command needs to be executed. Although, performing a VACUUM command as a few
drawbacks:

    - During a VACUUM twice the size of the original database file is required in disk.
    - During the VACUUM operation no access to the database is allowed.
    - The VACUUM operation copies the whole database which can take minutes.

For these reasons the VACUUM command cannot be performed after each operation. When possible we will avoid creating fragmented space. For
example, during a truncate operation we may prefer remove a whole SQLilte file instead of deleting part of is content. Another consequence
of the fragmented space is that DiskQuota will not be compatible with this blobstore.

* MBTiles Granularity *

Reading and writing tiles on an SQLite database will be slower than writing on a file system but will allow us to avoid file system
headaches. In order to limit the amount of contention on each single MBTiles file we will allow users to decide the granularity of the files
so that instead of having a single file for each single layer we will allow users to have more granularity.

MBTiles force us to have at least a file per layer and format. If we want to support more CRSs we will also need a file for each CRSs. By
configuration it will be possible to configure the granularity of the database files. By default we will have a granularity per layer, crs,
format and zoom level. As an instance something like this could be offered:

    <blobstore>
       <file>/path/to/{grid}/{dim}/{tileset}/{z}/{x}-{y}.sqlite</file>
       <xcount>1000</xcount>
       <ycount>1000</ycount>
    </blobstore>

In this case we should include the {x}, {y} and {z} replacements in the template determining the file to use. In the previous example, tile
(z,x,y)=(15,3024,1534) would be stored in a file named /path/to/g/mytileset/15/3000-1000.sqlite3 and tile (5,2,8) would be stored in a file
named /path/to/g/mytileset/5/0-0.sqlite3.

With more databases files we have more performance but we will have also more files to manage on the file system. In addition we can couple
this with the in-memory cache in order to improve tile serving performance.

* Connection Pooling and Performance *

SQLite allow multiple readers but only allow one writer at the time which will block the entire database. At most only one connection should
be open to each SQLite database, the total number of open connections is limited by the number of open files allowed by the OS (in linux
this is controlled by the ulimit). A connection pool that will control the number of open connections and that will be responsible to manage
the connections will be implemented.

* Replace Operation *

As said before, if the cache is running we cannot simply switch SQLite files, we need to make sure that all connections are closed. A
replace operation will be created for this propose. The replace operation will first copy the new file side by side the old one, then block
the requests to the old file, tear down the store, delete the old one, rename the new file to current one, reopen the new db file and start
serving requests again. Should be almost instant. A REST entry point for this operation will be created (with the possibility to send the
new file with the request).

Regards,

--

GeoServer Professional Services from the experts!
Visit http://goo.gl/it488V for more information.

Nuno Miguel Carvalho Oliveira
@nmcoliveira
Software Engineer

GeoSolutions S.A.S.
Via di Montramito 3/A
55054 Massarosa (LU)
Italy

phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 333 8128928

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

-------------------------------------------------------

AVVERTENZE AI SENSI DEL D.Lgs. 196/2003
Le informazioni contenute in questo messaggio di posta elettronica e/o nel/i file/s allegato/i sono
da considerarsi strettamente riservate. Il loro utilizzo è consentito esclusivamente al destinatario del messaggio, per le finalità indicate
nel messaggio stesso. Qualora riceviate questo messaggio senza esserne il destinatario, Vi preghiamo cortesemente di darcene notizia via e
-mail e di procedere alla distruzione del messaggio stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso, divulgarlo
anche in parte, distribuirlo ad altri soggetti, copiarlo, od utilizzarlo per finalità diverse, costituisce comportamento contrario ai
principi dettati dal D.Lgs. 196/2003.

The information in this message and/or attachments, is intended solely for the attention and use of
the named addressee(s) and may be confidential or proprietary in nature or covered by the provisions of privacy act (Legislative Decree
June, 30 2003, no.196 - Italy's New Data Protection Code).Any use not in accord with its purpose, any disclosure, reproduction, copying,
distribution, or either dissemination, either whole or partial, is strictly forbidden except previous formal approval of the named
addressee(s). If you are not the intended recipient, please contact immediately the sender by telephone, fax or e-mail and delete the
information in this message that has been received in error. The sender does not give any warranty or accept liability as the content,
accuracy or completeness of sent messages and accepts no responsibility for changes made after they were sent or for other risks which
arise as a result of e-mail transmission, viruses, etc.

SQLite files cannot be managed as simple files. When connections to an SQLite
database are open we should not delete, move or switch the associated file.
Databases files can be filled with "empty space" after deleting an huge amount
of data or can become fragmented after frequent inserts, updates or delete
operations.

Fragmentation would depend on cache behaviour. Would be worth testing representative load.

To remove the fragmented space (or the empty space), the VACUUM command
needs to be executed. Although, performing a VACUUM command as a few
drawbacks:

    - During a VACUUM twice the size of the original database file is required in
disk.
    - During the VACUUM operation no access to the database is allowed.
    - The VACUUM operation copies the whole database which can take minutes.

There is also auto_vacuum, which works quite differently but may be useful:
https://www.sqlite.org/pragma.html#pragma_auto_vacuum

Without that, or VACUUM, the cache will probably continue to grow.

MBTiles force us to have at least a file per layer and format. If we want to
support more CRSs we will also need a file for each CRSs. By configuration it
will be possible to configure the granularity of the database files. By default
we will have a granularity per layer, crs, format and zoom level.

Strictly speaking MBTiles is only web-mercator:
https://github.com/mapbox/mbtiles-spec/blob/master/1.2/spec.md#content-1

That may not be a big issue, but we should be cautious about how we refer to it.

SQLite allow multiple readers but only allow one writer at the time which will
block the entire database. At most only one connection should be open to each
SQLite database, the total number of open connections is limited by the
number of open files allowed by the OS (in linux this is controlled by the
ulimit). A connection pool that will control the number of open connections
and that will be responsible to manage the connections will be implemented.

Shared store is almost certainly a bad idea.

Brad

Hi Nuno,

If I understood correctly, Dave Blasby's presentation about vector tiles at FOSS4G NA two weeks ago made it sound like there was already something that GWC could do for some of the vector tile formats.

I take it that MBtiles are outside of that basic GWC integration?

Anyhow, I'm excited to see GeoServer/GWC have improved vector tile support!

Cheers,

Jim

On 05/19/2016 06:00 AM, Nuno Oliveira wrote:

Hi all,
sorry for the cross posting.

We would like to add MBTiles support to GWC.
Follows a description of the work with the main issues\limitations.

I would like to have community feedback on this, by the way is there a better way to propose this work ?

* MBtiles and SQLitle *

MBtiles is a specification that describe how to store tiles in an SQLite database, this will allow us to store many tiles in a single SQLite
file avoiding us file systems headaches:
https://github.com/mapbox/mbtiles-spec/blob/master/1.1/spec.md.

We can rely on GeoTools gt-mbtiles module for reading and writing MBTiles, this way most of the work of implementing this blobstore will be
managing SQLite connections and SQLite files.

SQLite files cannot be managed as simple files. When connections to an SQLite database are open we should not delete, move or switch the
associated file. Databases files can be filled with "empty space" after deleting an huge amount of data or can become fragmented after
frequent inserts, updates or delete operations.

SQLite documentation warns us against putting databases files on a shared file system if multiple process need access to it (which is our
case). Unless we can rely on a distributed lock mechanism SQLite databases files should not be used with shared stores.

* VACUUM and DiskQuota *

To remove the fragmented space (or the empty space), the VACUUM command needs to be executed. Although, performing a VACUUM command as a few
drawbacks:

     - During a VACUUM twice the size of the original database file is required in disk.
     - During the VACUUM operation no access to the database is allowed.
     - The VACUUM operation copies the whole database which can take minutes.

For these reasons the VACUUM command cannot be performed after each operation. When possible we will avoid creating fragmented space. For
example, during a truncate operation we may prefer remove a whole SQLilte file instead of deleting part of is content. Another consequence
of the fragmented space is that DiskQuota will not be compatible with this blobstore.

* MBTiles Granularity *

Reading and writing tiles on an SQLite database will be slower than writing on a file system but will allow us to avoid file system
headaches. In order to limit the amount of contention on each single MBTiles file we will allow users to decide the granularity of the files
so that instead of having a single file for each single layer we will allow users to have more granularity.

MBTiles force us to have at least a file per layer and format. If we want to support more CRSs we will also need a file for each CRSs. By
configuration it will be possible to configure the granularity of the database files. By default we will have a granularity per layer, crs,
format and zoom level. As an instance something like this could be offered:

     <blobstore>
        <file>/path/to/{grid}/{dim}/{tileset}/{z}/{x}-{y}.sqlite</file>
        <xcount>1000</xcount>
        <ycount>1000</ycount>
     </blobstore>

In this case we should include the {x}, {y} and {z} replacements in the template determining the file to use. In the previous example, tile
(z,x,y)=(15,3024,1534) would be stored in a file named /path/to/g/mytileset/15/3000-1000.sqlite3 and tile (5,2,8) would be stored in a file
named /path/to/g/mytileset/5/0-0.sqlite3.

With more databases files we have more performance but we will have also more files to manage on the file system. In addition we can couple
this with the in-memory cache in order to improve tile serving performance.

* Connection Pooling and Performance *

SQLite allow multiple readers but only allow one writer at the time which will block the entire database. At most only one connection should
be open to each SQLite database, the total number of open connections is limited by the number of open files allowed by the OS (in linux
this is controlled by the ulimit). A connection pool that will control the number of open connections and that will be responsible to manage
the connections will be implemented.

* Replace Operation *

As said before, if the cache is running we cannot simply switch SQLite files, we need to make sure that all connections are closed. A
replace operation will be created for this propose. The replace operation will first copy the new file side by side the old one, then block
the requests to the old file, tear down the store, delete the old one, rename the new file to current one, reopen the new db file and start
serving requests again. Should be almost instant. A REST entry point for this operation will be created (with the possibility to send the
new file with the request).

Regards,

Thanks for the feedback.

Fragmentation would depend on cache behaviour. Would be worth testing representative load.

I don't know what a representative load could be. Some users may want to delete tiles
by zoom level, others by tiles range or others delete/update single tiles.

Strictly speaking MBTiles is only web-mercator:> https://github.com/mapbox/mbtiles-spec/blob/master/1.2/spec.md#content-1&gt; ;
That may not be a big issue, but we should be cautious about how we refer to it.

You are correct.

Shared store is almost certainly a bad idea.

Yes SQLitle based specifications should not be used with shared stores.

Le jeudi 19 mai 2016 à 20:36 +1000, Brad Hards a écrit :

> SQLite files cannot be managed as simple files. When connections to an SQLite
> database are open we should not delete, move or switch the associated file.
> Databases files can be filled with "empty space" after deleting an huge amount
> of data or can become fragmented after frequent inserts, updates or delete
> operations.
Fragmentation would depend on cache behaviour. Would be worth testing representative load.

> To remove the fragmented space (or the empty space), the VACUUM command
> needs to be executed. Although, performing a VACUUM command as a few
> drawbacks:
>
> - During a VACUUM twice the size of the original database file is required in
> disk.
> - During the VACUUM operation no access to the database is allowed.
> - The VACUUM operation copies the whole database which can take minutes.
There is also auto_vacuum, which works quite differently but may be useful:
https://www.sqlite.org/pragma.html#pragma_auto_vacuum

Without that, or VACUUM, the cache will probably continue to grow.

> MBTiles force us to have at least a file per layer and format. If we want to
> support more CRSs we will also need a file for each CRSs. By configuration it
> will be possible to configure the granularity of the database files. By default
> we will have a granularity per layer, crs, format and zoom level.
Strictly speaking MBTiles is only web-mercator:
https://github.com/mapbox/mbtiles-spec/blob/master/1.2/spec.md#content-1

That may not be a big issue, but we should be cautious about how we refer to it.

> SQLite allow multiple readers but only allow one writer at the time which will
> block the entire database. At most only one connection should be open to each
> SQLite database, the total number of open connections is limited by the
> number of open files allowed by the OS (in linux this is controlled by the
> ulimit). A connection pool that will control the number of open connections
> and that will be responsible to manage the connections will be implemented.
Shared store is almost certainly a bad idea.

Brad

--

GeoServer Professional Services from the experts!
Visit http://goo.gl/it488V for more information.

Nuno Miguel Carvalho Oliveira
@nmcoliveira
Software Engineer

GeoSolutions S.A.S.
Via di Montramito 3/A
55054 Massarosa (LU)
Italy

phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 333 8128928

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

-------------------------------------------------------

AVVERTENZE AI SENSI DEL D.Lgs. 196/2003
Le informazioni contenute in questo messaggio di posta elettronica e/o nel/i file/s allegato/i sono
da considerarsi strettamente riservate. Il loro utilizzo è consentito esclusivamente al destinatario del messaggio, per le finalità indicate
nel messaggio stesso. Qualora riceviate questo messaggio senza esserne il destinatario, Vi preghiamo cortesemente di darcene notizia via e
-mail e di procedere alla distruzione del messaggio stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso, divulgarlo
anche in parte, distribuirlo ad altri soggetti, copiarlo, od utilizzarlo per finalità diverse, costituisce comportamento contrario ai
principi dettati dal D.Lgs. 196/2003.

The information in this message and/or attachments, is intended solely for the attention and use of
the named addressee(s) and may be confidential or proprietary in nature or covered by the provisions of privacy act (Legislative Decree
June, 30 2003, no.196 - Italy's New Data Protection Code).Any use not in accord with its purpose, any disclosure, reproduction, copying,
distribution, or either dissemination, either whole or partial, is strictly forbidden except previous formal approval of the named
addressee(s). If you are not the intended recipient, please contact immediately the sender by telephone, fax or e-mail and delete the
information in this message that has been received in error. The sender does not give any warranty or accept liability as the content,
accuracy or completeness of sent messages and accepts no responsibility for changes made after they were sent or for other risks which
arise as a result of e-mail transmission, viruses, etc.

Ciao Jim,
you are probably confusing MBTiles with GeoPackage.

MBTiles are about raster tiles unfortunately:
https://github.com/mapbox/mbtiles-spec/blob/master/1.1/spec.md

GeoPackage will follow but only for raster tiles for the time being.

Regards,
Simone Giannecchini

GeoServer Professional Services from the experts!
Visit http://goo.gl/it488V for more information.

Ing. Simone Giannecchini
@simogeo
Founder/Director

GeoSolutions S.A.S.
Via di Montramito 3/A
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 333 8128928

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

-------------------------------------------------------
AVVERTENZE AI SENSI DEL D.Lgs. 196/2003
Le informazioni contenute in questo messaggio di posta elettronica e/o
nel/i file/s allegato/i sono da considerarsi strettamente riservate.
Il loro utilizzo è consentito esclusivamente al destinatario del
messaggio, per le finalità indicate nel messaggio stesso. Qualora
riceviate questo messaggio senza esserne il destinatario, Vi preghiamo
cortesemente di darcene notizia via e-mail e di procedere alla
distruzione del messaggio stesso, cancellandolo dal Vostro sistema.
Conservare il messaggio stesso, divulgarlo anche in parte,
distribuirlo ad altri soggetti, copiarlo, od utilizzarlo per finalità
diverse, costituisce comportamento contrario ai principi dettati dal
D.Lgs. 196/2003.

The information in this message and/or attachments, is intended solely
for the attention and use of the named addressee(s) and may be
confidential or proprietary in nature or covered by the provisions of
privacy act (Legislative Decree June, 30 2003, no.196 - Italy's New
Data Protection Code).Any use not in accord with its purpose, any
disclosure, reproduction, copying, distribution, or either
dissemination, either whole or partial, is strictly forbidden except
previous formal approval of the named addressee(s). If you are not the
intended recipient, please contact immediately the sender by
telephone, fax or e-mail and delete the information in this message
that has been received in error. The sender does not give any warranty
or accept liability as the content, accuracy or completeness of sent
messages and accepts no responsibility for changes made after they
were sent or for other risks which arise as a result of e-mail
transmission, viruses, etc.

On Thu, May 19, 2016 at 3:40 PM, Jim Hughes <jnh5y@anonymised.com> wrote:

Hi Nuno,

If I understood correctly, Dave Blasby's presentation about vector tiles
at FOSS4G NA two weeks ago made it sound like there was already
something that GWC could do for some of the vector tile formats.

I take it that MBtiles are outside of that basic GWC integration?

Anyhow, I'm excited to see GeoServer/GWC have improved vector tile support!

Cheers,

Jim

On 05/19/2016 06:00 AM, Nuno Oliveira wrote:

Hi all,
sorry for the cross posting.

We would like to add MBTiles support to GWC.
Follows a description of the work with the main issues\limitations.

I would like to have community feedback on this, by the way is there a better way to propose this work ?

* MBtiles and SQLitle *

MBtiles is a specification that describe how to store tiles in an SQLite database, this will allow us to store many tiles in a single SQLite
file avoiding us file systems headaches:
https://github.com/mapbox/mbtiles-spec/blob/master/1.1/spec.md.

We can rely on GeoTools gt-mbtiles module for reading and writing MBTiles, this way most of the work of implementing this blobstore will be
managing SQLite connections and SQLite files.

SQLite files cannot be managed as simple files. When connections to an SQLite database are open we should not delete, move or switch the
associated file. Databases files can be filled with "empty space" after deleting an huge amount of data or can become fragmented after
frequent inserts, updates or delete operations.

SQLite documentation warns us against putting databases files on a shared file system if multiple process need access to it (which is our
case). Unless we can rely on a distributed lock mechanism SQLite databases files should not be used with shared stores.

* VACUUM and DiskQuota *

To remove the fragmented space (or the empty space), the VACUUM command needs to be executed. Although, performing a VACUUM command as a few
drawbacks:

     - During a VACUUM twice the size of the original database file is required in disk.
     - During the VACUUM operation no access to the database is allowed.
     - The VACUUM operation copies the whole database which can take minutes.

For these reasons the VACUUM command cannot be performed after each operation. When possible we will avoid creating fragmented space. For
example, during a truncate operation we may prefer remove a whole SQLilte file instead of deleting part of is content. Another consequence
of the fragmented space is that DiskQuota will not be compatible with this blobstore.

* MBTiles Granularity *

Reading and writing tiles on an SQLite database will be slower than writing on a file system but will allow us to avoid file system
headaches. In order to limit the amount of contention on each single MBTiles file we will allow users to decide the granularity of the files
so that instead of having a single file for each single layer we will allow users to have more granularity.

MBTiles force us to have at least a file per layer and format. If we want to support more CRSs we will also need a file for each CRSs. By
configuration it will be possible to configure the granularity of the database files. By default we will have a granularity per layer, crs,
format and zoom level. As an instance something like this could be offered:

     <blobstore>
        <file>/path/to/{grid}/{dim}/{tileset}/{z}/{x}-{y}.sqlite</file>
        <xcount>1000</xcount>
        <ycount>1000</ycount>
     </blobstore>

In this case we should include the {x}, {y} and {z} replacements in the template determining the file to use. In the previous example, tile
(z,x,y)=(15,3024,1534) would be stored in a file named /path/to/g/mytileset/15/3000-1000.sqlite3 and tile (5,2,8) would be stored in a file
named /path/to/g/mytileset/5/0-0.sqlite3.

With more databases files we have more performance but we will have also more files to manage on the file system. In addition we can couple
this with the in-memory cache in order to improve tile serving performance.

* Connection Pooling and Performance *

SQLite allow multiple readers but only allow one writer at the time which will block the entire database. At most only one connection should
be open to each SQLite database, the total number of open connections is limited by the number of open files allowed by the OS (in linux
this is controlled by the ulimit). A connection pool that will control the number of open connections and that will be responsible to manage
the connections will be implemented.

* Replace Operation *

As said before, if the cache is running we cannot simply switch SQLite files, we need to make sure that all connections are closed. A
replace operation will be created for this propose. The replace operation will first copy the new file side by side the old one, then block
the requests to the old file, tear down the store, delete the old one, rename the new file to current one, reopen the new db file and start
serving requests again. Should be almost instant. A REST entry point for this operation will be created (with the possibility to send the
new file with the request).

Regards,

------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
_______________________________________________
Geoserver-devel mailing list
Geoserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel

Hi Nuno,
     A late reply; this looks very interesting!
One thought on the "Replace Operation" you describe - given the sensible aversion to VACUUM, how about doing the replace operation function at the SQLite level rather than the file-system level? So rather than just copying the file, you could SELECT the content from the old SQLite file and then INSERT it to a new one. This would function the same way as a "VACUUM", although would have a higher cost than doing it at the file-system level.

Also, if you have any questions about the how to design this optimised to SQLite's capabilities, I'd strongly suggest asking on the SQLite mailing list - they're a very helpful, friendly, and knowledgeable bunch.

Cheers,
Jonathan

On 19/05/2016 11:00, Nuno Oliveira wrote:

Hi all,
sorry for the cross posting.

We would like to add MBTiles support to GWC.
Follows a description of the work with the main issues\limitations.

I would like to have community feedback on this, by the way is there a better way to propose this work ?

* MBtiles and SQLitle *

MBtiles is a specification that describe how to store tiles in an SQLite database, this will allow us to store many tiles in a single SQLite
file avoiding us file systems headaches:
https://github.com/mapbox/mbtiles-spec/blob/master/1.1/spec.md.

We can rely on GeoTools gt-mbtiles module for reading and writing MBTiles, this way most of the work of implementing this blobstore will be
managing SQLite connections and SQLite files.

SQLite files cannot be managed as simple files. When connections to an SQLite database are open we should not delete, move or switch the
associated file. Databases files can be filled with "empty space" after deleting an huge amount of data or can become fragmented after
frequent inserts, updates or delete operations.

SQLite documentation warns us against putting databases files on a shared file system if multiple process need access to it (which is our
case). Unless we can rely on a distributed lock mechanism SQLite databases files should not be used with shared stores.

* VACUUM and DiskQuota *

To remove the fragmented space (or the empty space), the VACUUM command needs to be executed. Although, performing a VACUUM command as a few
drawbacks:

     - During a VACUUM twice the size of the original database file is required in disk.
     - During the VACUUM operation no access to the database is allowed.
     - The VACUUM operation copies the whole database which can take minutes.

For these reasons the VACUUM command cannot be performed after each operation. When possible we will avoid creating fragmented space. For
example, during a truncate operation we may prefer remove a whole SQLilte file instead of deleting part of is content. Another consequence
of the fragmented space is that DiskQuota will not be compatible with this blobstore.

* MBTiles Granularity *

Reading and writing tiles on an SQLite database will be slower than writing on a file system but will allow us to avoid file system
headaches. In order to limit the amount of contention on each single MBTiles file we will allow users to decide the granularity of the files
so that instead of having a single file for each single layer we will allow users to have more granularity.

MBTiles force us to have at least a file per layer and format. If we want to support more CRSs we will also need a file for each CRSs. By
configuration it will be possible to configure the granularity of the database files. By default we will have a granularity per layer, crs,
format and zoom level. As an instance something like this could be offered:

     <blobstore>
        <file>/path/to/{grid}/{dim}/{tileset}/{z}/{x}-{y}.sqlite</file>
        <xcount>1000</xcount>
        <ycount>1000</ycount>
     </blobstore>

In this case we should include the {x}, {y} and {z} replacements in the template determining the file to use. In the previous example, tile
(z,x,y)=(15,3024,1534) would be stored in a file named /path/to/g/mytileset/15/3000-1000.sqlite3 and tile (5,2,8) would be stored in a file
named /path/to/g/mytileset/5/0-0.sqlite3.

With more databases files we have more performance but we will have also more files to manage on the file system. In addition we can couple
this with the in-memory cache in order to improve tile serving performance.

* Connection Pooling and Performance *

SQLite allow multiple readers but only allow one writer at the time which will block the entire database. At most only one connection should
be open to each SQLite database, the total number of open connections is limited by the number of open files allowed by the OS (in linux
this is controlled by the ulimit). A connection pool that will control the number of open connections and that will be responsible to manage
the connections will be implemented.

* Replace Operation *

As said before, if the cache is running we cannot simply switch SQLite files, we need to make sure that all connections are closed. A
replace operation will be created for this propose. The replace operation will first copy the new file side by side the old one, then block
the requests to the old file, tear down the store, delete the old one, rename the new file to current one, reopen the new db file and start
serving requests again. Should be almost instant. A REST entry point for this operation will be created (with the possibility to send the
new file with the request).

Regards,

Hi,

Sorry I missed your reply.

I agree with you about the SQLite community I dived in their
mailing list and they seem very helpful :slight_smile:

Regarding the VACUUM operation, the main problem with this operation is that at
some moment it needs to be executed if we want to recover all the fragmented
space (auto-vacuum helps but will not give us all the fragmented space back).

Let me thing a little bit about doing the vacuum in the background
vs copying the content of the current database and will get back to you.

Regards,

Nuno Oliveira

Le samedi 28 mai 2016 à 16:20 +0100, Jonathan Moules a écrit :

Hi Nuno,
     A late reply; this looks very interesting!
One thought on the "Replace Operation" you describe - given the sensible
aversion to VACUUM, how about doing the replace operation function at
the SQLite level rather than the file-system level? So rather than just
copying the file, you could SELECT the content from the old SQLite file
and then INSERT it to a new one. This would function the same way as a
"VACUUM", although would have a higher cost than doing it at the
file-system level.

Also, if you have any questions about the how to design this optimised
to SQLite's capabilities, I'd strongly suggest asking on the SQLite
mailing list - they're a very helpful, friendly, and knowledgeable bunch.

Cheers,
Jonathan

On 19/05/2016 11:00, Nuno Oliveira wrote:
> Hi all,
> sorry for the cross posting.
>
> We would like to add MBTiles support to GWC.
> Follows a description of the work with the main issues\limitations.
>
> I would like to have community feedback on this, by the way is there a better way to propose this work ?
>
> * MBtiles and SQLitle *
>
> MBtiles is a specification that describe how to store tiles in an SQLite database, this will allow us to store many tiles in a single
> SQLite
> file avoiding us file systems headaches:
> https://github.com/mapbox/mbtiles-spec/blob/master/1.1/spec.md.
>
> We can rely on GeoTools gt-mbtiles module for reading and writing MBTiles, this way most of the work of implementing this blobstore will
> be
> managing SQLite connections and SQLite files.
>
> SQLite files cannot be managed as simple files. When connections to an SQLite database are open we should not delete, move or switch the
> associated file. Databases files can be filled with "empty space" after deleting an huge amount of data or can become fragmented after
> frequent inserts, updates or delete operations.
>
> SQLite documentation warns us against putting databases files on a shared file system if multiple process need access to it (which is
> our
> case). Unless we can rely on a distributed lock mechanism SQLite databases files should not be used with shared stores.
>
> * VACUUM and DiskQuota *
>
> To remove the fragmented space (or the empty space), the VACUUM command needs to be executed. Although, performing a VACUUM command as a
> few
> drawbacks:
>
> - During a VACUUM twice the size of the original database file is required in disk.
> - During the VACUUM operation no access to the database is allowed.
> - The VACUUM operation copies the whole database which can take minutes.
>
> For these reasons the VACUUM command cannot be performed after each operation. When possible we will avoid creating fragmented space.
> For
> example, during a truncate operation we may prefer remove a whole SQLilte file instead of deleting part of is content. Another
> consequence
> of the fragmented space is that DiskQuota will not be compatible with this blobstore.
>
> * MBTiles Granularity *
>
> Reading and writing tiles on an SQLite database will be slower than writing on a file system but will allow us to avoid file system
> headaches. In order to limit the amount of contention on each single MBTiles file we will allow users to decide the granularity of the
> files
> so that instead of having a single file for each single layer we will allow users to have more granularity.
>
> MBTiles force us to have at least a file per layer and format. If we want to support more CRSs we will also need a file for each CRSs.
> By
> configuration it will be possible to configure the granularity of the database files. By default we will have a granularity per layer,
> crs,
> format and zoom level. As an instance something like this could be offered:
>
> <blobstore>
> <file>/path/to/{grid}/{dim}/{tileset}/{z}/{x}-{y}.sqlite</file>
> <xcount>1000</xcount>
> <ycount>1000</ycount>
> </blobstore>
>
> In this case we should include the {x}, {y} and {z} replacements in the template determining the file to use. In the previous example,
> tile
> (z,x,y)=(15,3024,1534) would be stored in a file named /path/to/g/mytileset/15/3000-1000.sqlite3 and tile (5,2,8) would be stored in a
> file
> named /path/to/g/mytileset/5/0-0.sqlite3.
>
> With more databases files we have more performance but we will have also more files to manage on the file system. In addition we can
> couple
> this with the in-memory cache in order to improve tile serving performance.
>
> * Connection Pooling and Performance *
>
> SQLite allow multiple readers but only allow one writer at the time which will block the entire database. At most only one connection
> should
> be open to each SQLite database, the total number of open connections is limited by the number of open files allowed by the OS (in linux
> this is controlled by the ulimit). A connection pool that will control the number of open connections and that will be responsible to
> manage
> the connections will be implemented.
>
> * Replace Operation *
>
> As said before, if the cache is running we cannot simply switch SQLite files, we need to make sure that all connections are closed. A
> replace operation will be created for this propose. The replace operation will first copy the new file side by side the old one, then
> block
> the requests to the old file, tear down the store, delete the old one, rename the new file to current one, reopen the new db file and
> start
> serving requests again. Should be almost instant. A REST entry point for this operation will be created (with the possibility to send
> the
> new file with the request).
>
> Regards,
>

--

GeoServer Professional Services from the experts!
Visit http://goo.gl/it488V for more information.

Nuno Miguel Carvalho Oliveira
@nmcoliveira
Software Engineer

GeoSolutions S.A.S.
Via di Montramito 3/A
55054 Massarosa (LU)
Italy

phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 333 8128928

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

-------------------------------------------------------

AVVERTENZE AI SENSI DEL D.Lgs. 196/2003
Le informazioni contenute in questo messaggio di posta elettronica e/o nel/i file/s allegato/i sono
da considerarsi strettamente riservate. Il loro utilizzo è consentito esclusivamente al destinatario del messaggio, per le finalità indicate
nel messaggio stesso. Qualora riceviate questo messaggio senza esserne il destinatario, Vi preghiamo cortesemente di darcene notizia via e
-mail e di procedere alla distruzione del messaggio stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso, divulgarlo
anche in parte, distribuirlo ad altri soggetti, copiarlo, od utilizzarlo per finalità diverse, costituisce comportamento contrario ai
principi dettati dal D.Lgs. 196/2003.

The information in this message and/or attachments, is intended solely for the attention and use of
the named addressee(s) and may be confidential or proprietary in nature or covered by the provisions of privacy act (Legislative Decree
June, 30 2003, no.196 - Italy's New Data Protection Code).Any use not in accord with its purpose, any disclosure, reproduction, copying,
distribution, or either dissemination, either whole or partial, is strictly forbidden except previous formal approval of the named
addressee(s). If you are not the intended recipient, please contact immediately the sender by telephone, fax or e-mail and delete the
information in this message that has been received in error. The sender does not give any warranty or accept liability as the content,
accuracy or completeness of sent messages and accepts no responsibility for changes made after they were sent or for other risks which
arise as a result of e-mail transmission, viruses, etc.

Hi,

I end up implementing the replace operation at the system level. The replace operation
will mainly be used to replace existing store content with another content. For example,
I seed a bunch of MBTiles files and I want to propagate those changes among the others
stores.

Regards,

Nuno Oliveira

Le vendredi 03 juin 2016 à 10:25 +0100, Nuno Oliveira a écrit :

Hi,

Sorry I missed your reply.

I agree with you about the SQLite community I dived in their
mailing list and they seem very helpful :slight_smile:

Regarding the VACUUM operation, the main problem with this operation is that at
some moment it needs to be executed if we want to recover all the fragmented
space (auto-vacuum helps but will not give us all the fragmented space back).

Let me thing a little bit about doing the vacuum in the background
vs copying the content of the current database and will get back to you.

Regards,

Nuno Oliveira

Le samedi 28 mai 2016 à 16:20 +0100, Jonathan Moules a écrit :
> Hi Nuno,
> A late reply; this looks very interesting!
> One thought on the "Replace Operation" you describe - given the sensible
> aversion to VACUUM, how about doing the replace operation function at
> the SQLite level rather than the file-system level? So rather than just
> copying the file, you could SELECT the content from the old SQLite file
> and then INSERT it to a new one. This would function the same way as a
> "VACUUM", although would have a higher cost than doing it at the
> file-system level.
>
> Also, if you have any questions about the how to design this optimised
> to SQLite's capabilities, I'd strongly suggest asking on the SQLite
> mailing list - they're a very helpful, friendly, and knowledgeable bunch.
>
> Cheers,
> Jonathan
>
> On 19/05/2016 11:00, Nuno Oliveira wrote:
> > Hi all,
> > sorry for the cross posting.
> >
> > We would like to add MBTiles support to GWC.
> > Follows a description of the work with the main issues\limitations.
> >
> > I would like to have community feedback on this, by the way is there a better way to propose this work ?
> >
> > * MBtiles and SQLitle *
> >
> > MBtiles is a specification that describe how to store tiles in an SQLite database, this will allow us to store many tiles in a single
> > SQLite
> > file avoiding us file systems headaches:
> > https://github.com/mapbox/mbtiles-spec/blob/master/1.1/spec.md.
> >
> > We can rely on GeoTools gt-mbtiles module for reading and writing MBTiles, this way most of the work of implementing this blobstore
> > will
> > be
> > managing SQLite connections and SQLite files.
> >
> > SQLite files cannot be managed as simple files. When connections to an SQLite database are open we should not delete, move or switch
> > the
> > associated file. Databases files can be filled with "empty space" after deleting an huge amount of data or can become fragmented after
> > frequent inserts, updates or delete operations.
> >
> > SQLite documentation warns us against putting databases files on a shared file system if multiple process need access to it (which is
> > our
> > case). Unless we can rely on a distributed lock mechanism SQLite databases files should not be used with shared stores.
> >
> > * VACUUM and DiskQuota *
> >
> > To remove the fragmented space (or the empty space), the VACUUM command needs to be executed. Although, performing a VACUUM command as
> > a
> > few
> > drawbacks:
> >
> > - During a VACUUM twice the size of the original database file is required in disk.
> > - During the VACUUM operation no access to the database is allowed.
> > - The VACUUM operation copies the whole database which can take minutes.
> >
> > For these reasons the VACUUM command cannot be performed after each operation. When possible we will avoid creating fragmented space.
> > For
> > example, during a truncate operation we may prefer remove a whole SQLilte file instead of deleting part of is content. Another
> > consequence
> > of the fragmented space is that DiskQuota will not be compatible with this blobstore.
> >
> > * MBTiles Granularity *
> >
> > Reading and writing tiles on an SQLite database will be slower than writing on a file system but will allow us to avoid file system
> > headaches. In order to limit the amount of contention on each single MBTiles file we will allow users to decide the granularity of the
> > files
> > so that instead of having a single file for each single layer we will allow users to have more granularity.
> >
> > MBTiles force us to have at least a file per layer and format. If we want to support more CRSs we will also need a file for each CRSs.
> > By
> > configuration it will be possible to configure the granularity of the database files. By default we will have a granularity per
> > layer,
> > crs,
> > format and zoom level. As an instance something like this could be offered:
> >
> > <blobstore>
> > <file>/path/to/{grid}/{dim}/{tileset}/{z}/{x}-{y}.sqlite</file>
> > <xcount>1000</xcount>
> > <ycount>1000</ycount>
> > </blobstore>
> >
> > In this case we should include the {x}, {y} and {z} replacements in the template determining the file to use. In the previous example,
> > tile
> > (z,x,y)=(15,3024,1534) would be stored in a file named /path/to/g/mytileset/15/3000-1000.sqlite3 and tile (5,2,8) would be stored in a
> > file
> > named /path/to/g/mytileset/5/0-0.sqlite3.
> >
> > With more databases files we have more performance but we will have also more files to manage on the file system. In addition we can
> > couple
> > this with the in-memory cache in order to improve tile serving performance.
> >
> > * Connection Pooling and Performance *
> >
> > SQLite allow multiple readers but only allow one writer at the time which will block the entire database. At most only one connection
> > should
> > be open to each SQLite database, the total number of open connections is limited by the number of open files allowed by the OS (in
> > linux
> > this is controlled by the ulimit). A connection pool that will control the number of open connections and that will be responsible to
> > manage
> > the connections will be implemented.
> >
> > * Replace Operation *
> >
> > As said before, if the cache is running we cannot simply switch SQLite files, we need to make sure that all connections are closed. A
> > replace operation will be created for this propose. The replace operation will first copy the new file side by side the old one, then
> > block
> > the requests to the old file, tear down the store, delete the old one, rename the new file to current one, reopen the new db file and
> > start
> > serving requests again. Should be almost instant. A REST entry point for this operation will be created (with the possibility to send
> > the
> > new file with the request).
> >
> > Regards,
> >
>
>

--

GeoServer Professional Services from the experts!
Visit http://goo.gl/it488V for more information.

Nuno Miguel Carvalho Oliveira
@nmcoliveira
Software Engineer

GeoSolutions S.A.S.
Via di Montramito 3/A
55054 Massarosa (LU)
Italy

phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 333 8128928

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

-------------------------------------------------------

AVVERTENZE AI SENSI DEL D.Lgs. 196/2003
Le informazioni contenute in questo messaggio di posta elettronica e/o nel/i file/s allegato/i sono
da considerarsi strettamente riservate. Il loro utilizzo è consentito esclusivamente al destinatario del messaggio, per le finalità indicate
nel messaggio stesso. Qualora riceviate questo messaggio senza esserne il destinatario, Vi preghiamo cortesemente di darcene notizia via e
-mail e di procedere alla distruzione del messaggio stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso, divulgarlo
anche in parte, distribuirlo ad altri soggetti, copiarlo, od utilizzarlo per finalità diverse, costituisce comportamento contrario ai
principi dettati dal D.Lgs. 196/2003.

The information in this message and/or attachments, is intended solely for the attention and use of
the named addressee(s) and may be confidential or proprietary in nature or covered by the provisions of privacy act (Legislative Decree
June, 30 2003, no.196 - Italy's New Data Protection Code).Any use not in accord with its purpose, any disclosure, reproduction, copying,
distribution, or either dissemination, either whole or partial, is strictly forbidden except previous formal approval of the named
addressee(s). If you are not the intended recipient, please contact immediately the sender by telephone, fax or e-mail and delete the
information in this message that has been received in error. The sender does not give any warranty or accept liability as the content,
accuracy or completeness of sent messages and accepts no responsibility for changes made after they were sent or for other risks which
arise as a result of e-mail transmission, viruses, etc.

Hello,

The proposal has been added to GeoWebCAche wiki:
https://github.com/GeoWebCache/geowebcache/wiki/MBTiles-BlobStore

I just made a pull request for this work:
https://github.com/GeoWebCache/geowebcache/pull/388

Regards,

Nuno Oliveira

Le jeudi 19 mai 2016 à 11:00 +0100, Nuno Oliveira a écrit :

Hi all,
sorry for the cross posting.

We would like to add MBTiles support to GWC.
Follows a description of the work with the main issues\limitations.

I would like to have community feedback on this, by the way is there a better way to propose this work ?

* MBtiles and SQLitle *

MBtiles is a specification that describe how to store tiles in an SQLite database, this will allow us to store many tiles in a single
SQLite
file avoiding us file systems headaches:
https://github.com/mapbox/mbtiles-spec/blob/master/1.1/spec.md.

We can rely on GeoTools gt-mbtiles module for reading and writing MBTiles, this way most of the work of implementing this blobstore will
be
managing SQLite connections and SQLite files.

SQLite files cannot be managed as simple files. When connections to an SQLite database are open we should not delete, move or switch the
associated file. Databases files can be filled with "empty space" after deleting an huge amount of data or can become fragmented after
frequent inserts, updates or delete operations.

SQLite documentation warns us against putting databases files on a shared file system if multiple process need access to it (which is our
case). Unless we can rely on a distributed lock mechanism SQLite databases files should not be used with shared stores.

* VACUUM and DiskQuota *

To remove the fragmented space (or the empty space), the VACUUM command needs to be executed. Although, performing a VACUUM command as a
few
drawbacks:

    - During a VACUUM twice the size of the original database file is required in disk.
    - During the VACUUM operation no access to the database is allowed.
    - The VACUUM operation copies the whole database which can take minutes.

For these reasons the VACUUM command cannot be performed after each operation. When possible we will avoid creating fragmented space. For
example, during a truncate operation we may prefer remove a whole SQLilte file instead of deleting part of is content. Another consequence
of the fragmented space is that DiskQuota will not be compatible with this blobstore.

* MBTiles Granularity *

Reading and writing tiles on an SQLite database will be slower than writing on a file system but will allow us to avoid file system
headaches. In order to limit the amount of contention on each single MBTiles file we will allow users to decide the granularity of the
files
so that instead of having a single file for each single layer we will allow users to have more granularity.

MBTiles force us to have at least a file per layer and format. If we want to support more CRSs we will also need a file for each CRSs. By
configuration it will be possible to configure the granularity of the database files. By default we will have a granularity per layer,
crs,
format and zoom level. As an instance something like this could be offered:

    <blobstore>
       <file>/path/to/{grid}/{dim}/{tileset}/{z}/{x}-{y}.sqlite</file>
       <xcount>1000</xcount>
       <ycount>1000</ycount>
    </blobstore>

In this case we should include the {x}, {y} and {z} replacements in the template determining the file to use. In the previous example,
tile
(z,x,y)=(15,3024,1534) would be stored in a file named /path/to/g/mytileset/15/3000-1000.sqlite3 and tile (5,2,8) would be stored in a
file
named /path/to/g/mytileset/5/0-0.sqlite3.

With more databases files we have more performance but we will have also more files to manage on the file system. In addition we can
couple
this with the in-memory cache in order to improve tile serving performance.

* Connection Pooling and Performance *

SQLite allow multiple readers but only allow one writer at the time which will block the entire database. At most only one connection
should
be open to each SQLite database, the total number of open connections is limited by the number of open files allowed by the OS (in linux
this is controlled by the ulimit). A connection pool that will control the number of open connections and that will be responsible to
manage
the connections will be implemented.

* Replace Operation *

As said before, if the cache is running we cannot simply switch SQLite files, we need to make sure that all connections are closed. A
replace operation will be created for this propose. The replace operation will first copy the new file side by side the old one, then
block
the requests to the old file, tear down the store, delete the old one, rename the new file to current one, reopen the new db file and
start
serving requests again. Should be almost instant. A REST entry point for this operation will be created (with the possibility to send the
new file with the request).

Regards,

--

GeoServer Professional Services from the experts!
Visit http://goo.gl/it488V for more information.

Nuno Miguel Carvalho Oliveira
@nmcoliveira
Software Engineer

GeoSolutions S.A.S.
Via di Montramito 3/A
55054 Massarosa (LU)
Italy

phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 333 8128928

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

-------------------------------------------------------

AVVERTENZE AI SENSI DEL D.Lgs. 196/2003
Le informazioni contenute in questo messaggio di posta elettronica e/o nel/i file/s allegato/i sono
da considerarsi strettamente riservate. Il loro utilizzo è consentito esclusivamente al destinatario del messaggio, per le finalità indicate
nel messaggio stesso. Qualora riceviate questo messaggio senza esserne il destinatario, Vi preghiamo cortesemente di darcene notizia via e
-mail e di procedere alla distruzione del messaggio stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso, divulgarlo
anche in parte, distribuirlo ad altri soggetti, copiarlo, od utilizzarlo per finalità diverse, costituisce comportamento contrario ai
principi dettati dal D.Lgs. 196/2003.

The information in this message and/or attachments, is intended solely for the attention and use of
the named addressee(s) and may be confidential or proprietary in nature or covered by the provisions of privacy act (Legislative Decree
June, 30 2003, no.196 - Italy's New Data Protection Code).Any use not in accord with its purpose, any disclosure, reproduction, copying,
distribution, or either dissemination, either whole or partial, is strictly forbidden except previous formal approval of the named
addressee(s). If you are not the intended recipient, please contact immediately the sender by telephone, fax or e-mail and delete the
information in this message that has been received in error. The sender does not give any warranty or accept liability as the content,
accuracy or completeness of sent messages and accepts no responsibility for changes made after they were sent or for other risks which
arise as a result of e-mail transmission, viruses, etc.

Hi,

I also made a pull request in GeoServer for a community module that will integrate the MBTiles store:
https://github.com/geoserver/geoserver/pull/1634

Regards,

Le mercredi 08 juin 2016 à 18:00 +0100, Nuno Oliveira a écrit :

Hello,

The proposal has been added to GeoWebCAche wiki:
https://github.com/GeoWebCache/geowebcache/wiki/MBTiles-BlobStore

I just made a pull request for this work:
https://github.com/GeoWebCache/geowebcache/pull/388

Regards,

Nuno Oliveira

Le jeudi 19 mai 2016 à 11:00 +0100, Nuno Oliveira a écrit :
> Hi all,
> sorry for the cross posting.
>
> We would like to add MBTiles support to GWC.
> Follows a description of the work with the main issues\limitations.
>
> I would like to have community feedback on this, by the way is there a better way to propose this work ?
>
> * MBtiles and SQLitle *
>
> MBtiles is a specification that describe how to store tiles in an SQLite database, this will allow us to store many tiles in a single
> SQLite
> file avoiding us file systems headaches:
> https://github.com/mapbox/mbtiles-spec/blob/master/1.1/spec.md.
>
> We can rely on GeoTools gt-mbtiles module for reading and writing MBTiles, this way most of the work of implementing this blobstore will
> be
> managing SQLite connections and SQLite files.
>
> SQLite files cannot be managed as simple files. When connections to an SQLite database are open we should not delete, move or switch the
> associated file. Databases files can be filled with "empty space" after deleting an huge amount of data or can become fragmented after
> frequent inserts, updates or delete operations.
>
> SQLite documentation warns us against putting databases files on a shared file system if multiple process need access to it (which is
> our
> case). Unless we can rely on a distributed lock mechanism SQLite databases files should not be used with shared stores.
>
> * VACUUM and DiskQuota *
>
> To remove the fragmented space (or the empty space), the VACUUM command needs to be executed. Although, performing a VACUUM command as a
> few
> drawbacks:
>
> - During a VACUUM twice the size of the original database file is required in disk.
> - During the VACUUM operation no access to the database is allowed.
> - The VACUUM operation copies the whole database which can take minutes.
>
> For these reasons the VACUUM command cannot be performed after each operation. When possible we will avoid creating fragmented space.
> For
> example, during a truncate operation we may prefer remove a whole SQLilte file instead of deleting part of is content. Another
> consequence
> of the fragmented space is that DiskQuota will not be compatible with this blobstore.
>
> * MBTiles Granularity *
>
> Reading and writing tiles on an SQLite database will be slower than writing on a file system but will allow us to avoid file system
> headaches. In order to limit the amount of contention on each single MBTiles file we will allow users to decide the granularity of the
> files
> so that instead of having a single file for each single layer we will allow users to have more granularity.
>
> MBTiles force us to have at least a file per layer and format. If we want to support more CRSs we will also need a file for each CRSs.
> By
> configuration it will be possible to configure the granularity of the database files. By default we will have a granularity per layer,
> crs,
> format and zoom level. As an instance something like this could be offered:
>
> <blobstore>
> <file>/path/to/{grid}/{dim}/{tileset}/{z}/{x}-{y}.sqlite</file>
> <xcount>1000</xcount>
> <ycount>1000</ycount>
> </blobstore>
>
> In this case we should include the {x}, {y} and {z} replacements in the template determining the file to use. In the previous example,
> tile
> (z,x,y)=(15,3024,1534) would be stored in a file named /path/to/g/mytileset/15/3000-1000.sqlite3 and tile (5,2,8) would be stored in a
> file
> named /path/to/g/mytileset/5/0-0.sqlite3.
>
> With more databases files we have more performance but we will have also more files to manage on the file system. In addition we can
> couple
> this with the in-memory cache in order to improve tile serving performance.
>
> * Connection Pooling and Performance *
>
> SQLite allow multiple readers but only allow one writer at the time which will block the entire database. At most only one connection
> should
> be open to each SQLite database, the total number of open connections is limited by the number of open files allowed by the OS (in linux
> this is controlled by the ulimit). A connection pool that will control the number of open connections and that will be responsible to
> manage
> the connections will be implemented.
>
> * Replace Operation *
>
> As said before, if the cache is running we cannot simply switch SQLite files, we need to make sure that all connections are closed. A
> replace operation will be created for this propose. The replace operation will first copy the new file side by side the old one, then
> block
> the requests to the old file, tear down the store, delete the old one, rename the new file to current one, reopen the new db file and
> start
> serving requests again. Should be almost instant. A REST entry point for this operation will be created (with the possibility to send
> the
> new file with the request).
>
> Regards,
>

--

GeoServer Professional Services from the experts!
Visit http://goo.gl/it488V for more information.

Nuno Miguel Carvalho Oliveira
@nmcoliveira
Software Engineer

GeoSolutions S.A.S.
Via di Montramito 3/A
55054 Massarosa (LU)
Italy

phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 333 8128928

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

-------------------------------------------------------

AVVERTENZE AI SENSI DEL D.Lgs. 196/2003
Le informazioni contenute in questo messaggio di posta elettronica e/o nel/i file/s allegato/i sono
da considerarsi strettamente riservate. Il loro utilizzo è consentito esclusivamente al destinatario del messaggio, per le finalità indicate
nel messaggio stesso. Qualora riceviate questo messaggio senza esserne il destinatario, Vi preghiamo cortesemente di darcene notizia via e
-mail e di procedere alla distruzione del messaggio stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso, divulgarlo
anche in parte, distribuirlo ad altri soggetti, copiarlo, od utilizzarlo per finalità diverse, costituisce comportamento contrario ai
principi dettati dal D.Lgs. 196/2003.

The information in this message and/or attachments, is intended solely for the attention and use of
the named addressee(s) and may be confidential or proprietary in nature or covered by the provisions of privacy act (Legislative Decree
June, 30 2003, no.196 - Italy's New Data Protection Code).Any use not in accord with its purpose, any disclosure, reproduction, copying,
distribution, or either dissemination, either whole or partial, is strictly forbidden except previous formal approval of the named
addressee(s). If you are not the intended recipient, please contact immediately the sender by telephone, fax or e-mail and delete the
information in this message that has been received in error. The sender does not give any warranty or accept liability as the content,
accuracy or completeness of sent messages and accepts no responsibility for changes made after they were sent or for other risks which
arise as a result of e-mail transmission, viruses, etc.

Hi,
   I'm confused with some questions.
   1.what does the "xcount" and "ycount" mean?
   2."In the previous example, tile
(z,x,y)=(15,3024,1534) would be stored in a file named
/path/to/g/mytileset/15/3000-1000.sqlite3 and tile (5,2,8) would be stored
in a file
named /path/to/g/mytileset/5/0-0.sqlite3. "-------The values for x and y
are greater than the corresponding values in the file name?
  3.mbtiles is usually a single file.If I want to use this plugin , i have
to split it into several sqlite files?
   
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Adding-MBTiles-Support-in-GWC-tp5267168p5311316.html
Sent from the GeoServer - Dev mailing list archive at Nabble.com.

Hi,
please read my answers bellow:

I guess that by “xcount” and “ycount” you are referring to the “rowRangeCount” and “columnRangeCount” properties. As said in the documentation (): These properties when used with path template terms “y” and “x” allow you to control the maximum number of tiles per MBTiles file. The default configuration and file template ({layer}/{grid}{format}{params}/{z}-{x}-{y}.sqlite) will make each MBTiles contain at max 250*250 tiles. So file 20-0-250.sqlite will contain tiles for zoom level 20, X tiles 0 to 250 and Y tiles 250 to 500. I don’t know which values you used for “rowRangeCount” and “columnRangeCount” but let’s say you use 1000 thousand for both. File ‘/path/to/g/mytileset/15/3000-1000.sqlite3’ will contain X tiles from 3000 to 4000 and Y tiles from 1000 to 2000. File ‘/path/to/g/mytileset/5/0-0.sqlite3’ will contain X tiles from 0 to 1000 and Y tiles from 0 to 1000. The range count is equal for both X and Y in this case. You don’t need to create several files, the path template just give you options to control the granularity of the databases files. The MBTiles specification () defines several restrictions regarding the content of the MBTiles files (one layer per file, one image format per file, etc …). I don’t know what you are trying to achieve (creating MBTiles files to be consumed by another application ?), in this case your template could look like this: {layer}/{params}/{grid}/{format}/mbtiles.sqlite Is up to you to define the path template that suits you the best, you need to take in consideration your use case and performance requirements. Hope it helps. Regards, Nuno Oliveira

···

On 03/08/2017 07:29 AM, kg_loveyou wrote:

Hi,
   I'm confused with some questions.
   1.what does the "xcount" and "ycount" mean?

http://docs.geoserver.org/stable/en/user/community/gwc-sqlite/index.html

The *templatePath* property is used to control the granularity of the database files (see section above).
Properties *rowRangeCount* and *columnRangeCount* will be used by the path template to compute tile ranges.
   2."In the previous example, tile 
(z,x,y)=(15,3024,1534) would be stored in a file named
/path/to/g/mytileset/15/3000-1000.sqlite3 and tile (5,2,8) would be stored
in a file 
named /path/to/g/mytileset/5/0-0.sqlite3. "-------The values for x and y 
are greater than the corresponding values in the file name?
  3.mbtiles is usually a single file.If I want to use this plugin , i have
to split it into several sqlite files?

https://github.com/mapbox/mbtiles-spec/blob/master/1.1/spec.md

-- 
==
GeoServer Professional Services from the experts! 
Visit [http://goo.gl/it488V](http://goo.gl/it488V) for more information.
==
Nuno Miguel Carvalho Oliveira
@nmcoliveira
Software Engineer

GeoSolutions S.A.S.
Via di Montramito 3/A
55054  Massarosa (LU)
Italy

phone: +39 0584 962313
fax:   +39 0584 1660272
mob:   +39  333 8128928

[http://www.geo-solutions.it](http://www.geo-solutions.it)
[http://twitter.com/geosolutions_it](http://twitter.com/geosolutions_it)

-------------------------------------------------------

AVVERTENZE AI SENSI DEL D.Lgs. 196/2003
Le informazioni contenute in questo messaggio di posta elettronica e/o nel/i file/s allegato/i sono
da considerarsi strettamente riservate. Il loro utilizzo è consentito esclusivamente al destinatario del messaggio, per le finalità indicate
nel messaggio stesso. Qualora riceviate questo messaggio senza esserne il destinatario, Vi preghiamo cortesemente di darcene notizia via e
-mail e di procedere alla distruzione del messaggio stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso, divulgarlo
anche in parte, distribuirlo ad altri soggetti, copiarlo, od utilizzarlo per finalità diverse, costituisce comportamento contrario ai
principi dettati dal D.Lgs. 196/2003.
 
The information in this message and/or attachments, is intended solely for the attention and use of
the named addressee(s) and may be confidential or proprietary in nature or covered by the provisions of privacy act (Legislative Decree
June, 30 2003, no.196 - Italy's New Data Protection Code).Any use not in accord with its purpose, any disclosure, reproduction, copying,
distribution, or either dissemination, either whole or partial, is strictly forbidden except previous formal approval of the named
addressee(s). If you are not the intended recipient, please contact immediately the sender by telephone, fax or e-mail and delete the
information in this message that has been received in error. The sender does not give any warranty or accept liability as the content,
accuracy or completeness of sent messages and accepts no responsibility  for changes made after they were sent or for other risks which
arise as a result of e-mail transmission, viruses, etc.

Thanks for your reply!
     I have created the mbtiles file by another application(TillMill),the
mbtiles file named *.mbtiles and the type is baselayer.
     Now,i want to publish the mbtiles as wmts serverice and call it. How
can i make it?

--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Adding-MBTiles-Support-in-GWC-tp5267168p5311514.html
Sent from the GeoServer - Dev mailing list archive at Nabble.com.

I have never done it, but if you place you files in the path GS\GWC will expected them for a particular layer and make sure you don't have any tiles expiration activated otherwise GeoServer will truncate\seed some of your tiles. Let us know if you manage to do it.

On 03/09/2017 02:21 AM, kg_loveyou wrote:

Thanks for your reply!
      I have created the mbtiles file by another application(TillMill),the
mbtiles file named *.mbtiles and the type is baselayer.
      Now,i want to publish the mbtiles as wmts serverice and call it. How
can i make it?
  
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Adding-MBTiles-Support-in-GWC-tp5267168p5311514.html
Sent from the GeoServer - Dev mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford
_______________________________________________
Geoserver-devel mailing list
Geoserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel

--

GeoServer Professional Services from the experts!
Visit http://goo.gl/it488V for more information.

Nuno Miguel Carvalho Oliveira
@nmcoliveira
Software Engineer

GeoSolutions S.A.S.
Via di Montramito 3/A
55054 Massarosa (LU)
Italy

phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 333 8128928

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

-------------------------------------------------------

AVVERTENZE AI SENSI DEL D.Lgs. 196/2003
Le informazioni contenute in questo messaggio di posta elettronica e/o nel/i file/s allegato/i sono
da considerarsi strettamente riservate. Il loro utilizzo è consentito esclusivamente al destinatario del messaggio, per le finalità indicate
nel messaggio stesso. Qualora riceviate questo messaggio senza esserne il destinatario, Vi preghiamo cortesemente di darcene notizia via e
-mail e di procedere alla distruzione del messaggio stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso, divulgarlo
anche in parte, distribuirlo ad altri soggetti, copiarlo, od utilizzarlo per finalità diverse, costituisce comportamento contrario ai
principi dettati dal D.Lgs. 196/2003.
  The information in this message and/or attachments, is intended solely for the attention and use of
the named addressee(s) and may be confidential or proprietary in nature or covered by the provisions of privacy act (Legislative Decree
June, 30 2003, no.196 - Italy's New Data Protection Code).Any use not in accord with its purpose, any disclosure, reproduction, copying,
distribution, or either dissemination, either whole or partial, is strictly forbidden except previous formal approval of the named
addressee(s). If you are not the intended recipient, please contact immediately the sender by telephone, fax or e-mail and delete the
information in this message that has been received in error. The sender does not give any warranty or accept liability as the content,
accuracy or completeness of sent messages and accepts no responsibility for changes made after they were sent or for other risks which
arise as a result of e-mail transmission, viruses, etc.