Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to improve the efficiency of keystone

Shulou Source: shulou.com Published: 2022-06-01 17:11:39 09月29日 Update

This article introduces the relevant knowledge of "how to improve the efficiency of keystone". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Written in front of...

Recently, when I was testing the OpenStack Havana RDO version, I found that the whole platform would change more and more slowly after a period of time. At the beginning, there is no motivation to go to trouble shooting, after all, it is a demo environment. I couldn't stand it because I couldn't access it yesterday. We have to see what kind of bedbug is messing with it.

The problem with keystne Token

Inadvertently found that in the process of Nova API calls, in the process of getting Token from keystone will be unusually long. When I just finished installing keystone, the whole speed was pretty good. After consulting the relevant information, it is found that Token is permanently stored in the database, and the growth rate is still very fast. The table analysis of keystone database is as follows:

Switch to MySQL's own management library information_schema

Mysql > use information_schema;Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with-ADatabase changed

View the size of the Token:

Mysql > select data_length,index_length from tables where table_schema='keystone'- > and table_name='token' +-+-+ | data_length | index_length | +-+-+ | 916455424 | 17924096 | +-+-+ 1 row in set (0.01sec)

Look at it in a more intuitive way:

Mysql > select concat (round (sum (data_length/1024/1024), 2), 'MB') as data_length_MB,- > concat (round (sum (index_length/1024/1024), 2),' MB') as index_length_MB- > from tables where- > table_schema='keystone'- > and table_name='token' +-+-+ | data_length_MB | index_length_MB | +-+-+ | 874.00MB | 17.09MB | +-- -+ 1 row in set (0.01 sec)

About two weeks, there is nearly 1G of data, of course, 1G for the database is also a small case, but if it is a year, this amount of data can not be ignored.

Let's take a look at keystone's configuration of keystone.conf for token. There are several main parts:

[token] # Provides token persistence.driver = keystone.token.backends.sql.Token# driver = keystone.token.backends.memcache.Token# Controls the token construction, validation, and revocation operations.# Core providers are keystone.token.providers.[ PKI | uuid] .provider # provider = # Amount of time a token should remain valid (in seconds) expiration = 86400

From the above configuration, token can be stored in the database by default, and the default expiration time is one day. Of course, many friends on launchpad mentioned using scripts to clean up the database.

Solve the problem by clearing the token table

Here, we also learn from their experience to solve this problem. Here is the script to clear the token table.

#! / bin/bashmysql_user=mysql_password=mysql_host=# here you can consider the time to clear the data. Why is it 2 days mysql-u$ {mysql_user}-p$ {mysql_password}-h$ {mysql_host}-e 'USE keystone; DELETE FROM token WHERE NOT DATE_SUB (CURDATE (), INTERVAL 2 DAY)

Tags: Data script database time problem efficiency way time or storage service configuration information content more knowledge process speed permanent good Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Huawei MariaDB Apple Shulou Tech Info