Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
2bfcb1a8
Commit
2bfcb1a8
authored
Oct 04, 2016
by
Wojciech Tyczynski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set deserialization cache size based on target memory usage
parent
158dc1a8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
3 deletions
+29
-3
server.go
cmd/kube-apiserver/app/server.go
+22
-0
server.go
federation/cmd/federation-apiserver/app/server.go
+4
-0
server_run_options.go
pkg/genericapiserver/options/server_run_options.go
+3
-3
No files found.
cmd/kube-apiserver/app/server.go
View file @
2bfcb1a8
...
@@ -145,6 +145,28 @@ func Run(s *options.APIServer) error {
...
@@ -145,6 +145,28 @@ func Run(s *options.APIServer) error {
glog
.
Fatalf
(
"Failed to start kubelet client: %v"
,
err
)
glog
.
Fatalf
(
"Failed to start kubelet client: %v"
,
err
)
}
}
if
s
.
StorageConfig
.
DeserializationCacheSize
==
0
{
// When size of cache is not explicitly set, estimate its size based on
// target memory usage.
glog
.
V
(
2
)
.
Infof
(
"Initalizing deserialization cache size based on %dMB limit"
,
s
.
TargetRAMMB
)
// This is the heuristics that from memory capacity is trying to infer
// the maximum number of nodes in the cluster and set cache sizes based
// on that value.
// From our documentation, we officially recomment 120GB machines for
// 2000 nodes, and we scale from that point. Thus we assume ~60MB of
// capacity per node.
// TODO: We may consider deciding that some percentage of memory will
// be used for the deserialization cache and divide it by the max object
// size to compute its size. We may even go further and measure
// collective sizes of the objects in the cache.
clusterSize
:=
s
.
TargetRAMMB
/
60
s
.
StorageConfig
.
DeserializationCacheSize
=
25
*
clusterSize
if
s
.
StorageConfig
.
DeserializationCacheSize
<
1000
{
s
.
StorageConfig
.
DeserializationCacheSize
=
1000
}
}
storageGroupsToEncodingVersion
,
err
:=
s
.
StorageGroupsToEncodingVersion
()
storageGroupsToEncodingVersion
,
err
:=
s
.
StorageGroupsToEncodingVersion
()
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Fatalf
(
"error generating storage version map: %s"
,
err
)
glog
.
Fatalf
(
"error generating storage version map: %s"
,
err
)
...
...
federation/cmd/federation-apiserver/app/server.go
View file @
2bfcb1a8
...
@@ -82,6 +82,10 @@ func Run(s *options.ServerRunOptions) error {
...
@@ -82,6 +82,10 @@ func Run(s *options.ServerRunOptions) error {
// TODO: register cluster federation resources here.
// TODO: register cluster federation resources here.
resourceConfig
:=
genericapiserver
.
NewResourceConfig
()
resourceConfig
:=
genericapiserver
.
NewResourceConfig
()
if
s
.
StorageConfig
.
DeserializationCacheSize
==
0
{
// When size of cache is not explicitly set, set it to 50000
s
.
StorageConfig
.
DeserializationCacheSize
=
50000
}
storageGroupsToEncodingVersion
,
err
:=
s
.
StorageGroupsToEncodingVersion
()
storageGroupsToEncodingVersion
,
err
:=
s
.
StorageGroupsToEncodingVersion
()
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Fatalf
(
"error generating storage version map: %s"
,
err
)
glog
.
Fatalf
(
"error generating storage version map: %s"
,
err
)
...
...
pkg/genericapiserver/options/server_run_options.go
View file @
2bfcb1a8
...
@@ -37,8 +37,6 @@ import (
...
@@ -37,8 +37,6 @@ import (
)
)
const
(
const
(
DefaultDeserializationCacheSize
=
50000
// TODO: This can be tightened up. It still matches objects named watch or proxy.
// TODO: This can be tightened up. It still matches objects named watch or proxy.
defaultLongRunningRequestRE
=
"(/|^)((watch|proxy)(/|$)|(logs?|portforward|exec|attach)/?$)"
defaultLongRunningRequestRE
=
"(/|^)((watch|proxy)(/|$)|(logs?|portforward|exec|attach)/?$)"
)
)
...
@@ -158,7 +156,9 @@ func NewServerRunOptions() *ServerRunOptions {
...
@@ -158,7 +156,9 @@ func NewServerRunOptions() *ServerRunOptions {
func
(
o
*
ServerRunOptions
)
WithEtcdOptions
()
*
ServerRunOptions
{
func
(
o
*
ServerRunOptions
)
WithEtcdOptions
()
*
ServerRunOptions
{
o
.
StorageConfig
=
storagebackend
.
Config
{
o
.
StorageConfig
=
storagebackend
.
Config
{
Prefix
:
DefaultEtcdPathPrefix
,
Prefix
:
DefaultEtcdPathPrefix
,
DeserializationCacheSize
:
DefaultDeserializationCacheSize
,
// Default cache size to 0 - if unset, its size will be set based on target
// memory usage.
DeserializationCacheSize
:
0
,
}
}
return
o
return
o
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment