performance - OpenVZ, apache2 and wordpress: long first byte time -
i have openvz vps 400mb ram , 800mhz cpu. os debian 6. have install apache2 , wordpress.
i test site perfomance using web tool. test results here: http://www.webpagetest.org/result/130405_04_5tf/
all works fine, first byte time long. can't understand why apache long time not give static content.
why happening? can provide config files if needed.
apache2.conf:
lockfile ${apache_lock_dir}/accept.lock pidfile ${apache_pid_file} timeout 300 keepalive on maxkeepaliverequests 100 keepalivetimeout 15 <ifmodule mpm_prefork_module> startservers 1 minspareservers 1 maxspareservers 5 maxclients 10 maxrequestsperchild 0 </ifmodule> <ifmodule mpm_worker_module> startservers 1 minsparethreads 1 maxsparethreads 4 threadlimit 64 threadsperchild 25 maxclients 10 maxrequestsperchild 0 </ifmodule> <ifmodule mpm_event_module> startservers 1 maxclients 10 minsparethreads 1 maxsparethreads 4 threadlimit 64 threadsperchild 25 maxrequestsperchild 0 </ifmodule> user ${apache_run_user} group ${apache_run_group} accessfilename .htaccess <files ~ "^\.ht"> order allow,deny deny satisfy </files> defaulttype text/plain hostnamelookups off errorlog ${apache_log_dir}/error.log loglevel warn include mods-enabled/*.load include mods-enabled/*.conf include httpd.conf include ports.conf logformat "%v:%p %h %l %u %t \"%r\" %>s %o \"%{referer}i\" \"%{user-agent}i\"" vhost_combined logformat "%h %l %u %t \"%r\" %>s %o \"%{referer}i\" \"%{user-agent}i\"" combined logformat "%h %l %u %t \"%r\" %>s %o" common logformat "%{referer}i -> %u" referer logformat "%{user-agent}i" agent include conf.d/ include sites-enabled/
httpd.conf empty
.htaccess site (with w3 super cache directives):
# begin w3tc browser cache <ifmodule mod_mime.c> addtype text/css .css addtype text/x-component .htc addtype application/x-javascript .js addtype application/javascript .js2 addtype text/javascript .js3 addtype text/x-js .js4 </ifmodule> <ifmodule mod_expires.c> expiresactive on expiresbytype text/css a31536000 expiresbytype text/x-component a31536000 expiresbytype application/x-javascript a31536000 expiresbytype application/javascript a31536000 expiresbytype text/javascript a31536000 expiresbytype text/x-js a31536000 </ifmodule> <ifmodule mod_deflate.c> <ifmodule mod_headers.c> header append vary user-agent env=!dont-vary </ifmodule> addoutputfilterbytype deflate text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/json <ifmodule mod_mime.c> # deflate extension addoutputfilter deflate js css htm html xml </ifmodule> </ifmodule> <filesmatch "\.(css|htc|js|js2|js3|js4|css|htc|js|js2|js3|js4)$"> <ifmodule mod_headers.c> header set pragma "public" header append cache-control "public" header unset set-cookie </ifmodule> </filesmatch> <filesmatch "\.(html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml|html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml)$"> <ifmodule mod_headers.c> header set pragma "public" header set cache-control "max-age=86400, public" </ifmodule> </filesmatch> <filesmatch "\.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|json|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|xla|xls|xlsx|xlt|xlw|zip|asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|json|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|xla|xls|xlsx|xlt|xlw|zip)$"> <ifmodule mod_headers.c> header set pragma "public" header set cache-control "max-age=31536000, public" </ifmodule> </filesmatch> # end w3tc browser cache # begin wordpress # end wordpress <files wp-config.php> order deny,allow deny </files> <files setchmod> order deny,allow deny </files>
php.ini:
engine = on short_open_tag = on asp_tags = off precision = 14 y2k_compliance = on output_buffering = 4096 zlib.output_compression = off implicit_flush = off unserialize_callback_func = serialize_precision = 100 allow_call_time_pass_reference = off safe_mode = off safe_mode_gid = off safe_mode_include_dir = safe_mode_exec_dir = safe_mode_allowed_env_vars = php_ safe_mode_protected_env_vars = ld_library_path disable_functions = disable_classes = expose_php = on max_execution_time = 30 max_input_time = 60 memory_limit = 128m error_reporting = e_all & ~e_deprecated display_errors = off display_startup_errors = off log_errors = on log_errors_max_len = 1024 ignore_repeated_errors = off ignore_repeated_source = off report_memleaks = on track_errors = off html_errors = off variables_order = "gpcs" request_order = "gp" register_globals = off register_long_arrays = off register_argc_argv = off auto_globals_jit = on post_max_size = 8m magic_quotes_gpc = off magic_quotes_runtime = off magic_quotes_sybase = off auto_prepend_file = auto_append_file = default_mimetype = "text/html" doc_root = user_dir = enable_dl = off file_uploads = on upload_max_filesize = 2m max_file_uploads = 20 allow_url_fopen = on allow_url_include = off default_socket_timeout = 60 pdo_mysql.cache_size = 2000 pdo_mysql.default_socket= define_syslog_variables = off smtp = localhost smtp_port = 25 mail.add_x_header = on sql.safe_mode = off odbc.allow_persistent = on odbc.check_persistent = on odbc.max_persistent = -1 odbc.max_links = -1 odbc.defaultlrl = 4096 odbc.defaultbinmode = 1 ibase.allow_persistent = 1 ibase.max_persistent = -1 ibase.max_links = -1 ibase.timestampformat = "%y-%m-%d %h:%m:%s" ibase.dateformat = "%y-%m-%d" ibase.timeformat = "%h:%m:%s" mysql.allow_local_infile = on mysql.allow_persistent = on mysql.cache_size = 2000 mysql.max_persistent = -1 mysql.max_links = -1 mysql.default_port = mysql.default_socket = mysql.default_host = mysql.default_user = mysql.default_password = mysql.connect_timeout = 60 mysql.trace_mode = off mysqli.max_persistent = -1 mysqli.allow_persistent = on mysqli.max_links = -1 mysqli.cache_size = 2000 mysqli.default_port = 3306 mysqli.default_socket = mysqli.default_host = mysqli.default_user = mysqli.default_pw = mysqli.reconnect = off mysqlnd.collect_statistics = on mysqlnd.collect_memory_statistics = off pgsql.allow_persistent = on pgsql.auto_reset_persistent = off pgsql.max_persistent = -1 pgsql.max_links = -1 pgsql.ignore_notice = 0 pgsql.log_notice = 0 sybct.allow_persistent = on sybct.max_persistent = -1 sybct.max_links = -1 sybct.min_server_severity = 10 sybct.min_client_severity = 10 bcmath.scale = 0 session.save_handler = files session.use_cookies = 1 session.use_only_cookies = 1 session.name = phpsessid session.auto_start = 0 session.cookie_lifetime = 0 session.cookie_path = / session.cookie_domain = session.cookie_httponly = session.serialize_handler = php session.gc_probability = 0 session.gc_divisor = 1000 session.gc_maxlifetime = 1440 session.bug_compat_42 = off session.bug_compat_warn = off session.referer_check = session.entropy_length = 0 session.cache_limiter = nocache session.cache_expire = 180 session.use_trans_sid = 0 session.hash_function = 0 session.hash_bits_per_character = 5 url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry" mssql.allow_persistent = on mssql.max_persistent = -1 mssql.max_links = -1 mssql.min_error_severity = 10 mssql.min_message_severity = 10 mssql.compatability_mode = off mssql.secure_connection = off tidy.clean_output = off soap.wsdl_cache_enabled=1 soap.wsdl_cache_dir="/tmp" soap.wsdl_cache_ttl=86400 soap.wsdl_cache_limit = 5 ldap.max_links = -1
from waterfall view on results page can see takes more 0.5s dns lookup , establish connection server. takes 0.25s server process first request , reply http 302 redirect (to /?lang=en
).
as have correctly configured keep-alive, subsequent request re-use same connection. right after receiving redirect, client sends new request , waits until server processes (green bar on second line) - took server 0.7s, not good. took 0.15s download returned data server. other requests started second connection, images got downloaded on both connections in parallel.
the long time establish connection because of distance between server (estonia) , testing server (probably usa). thing can optimize 0.7s server needs generate homepage. maybe need tune mysql parameters or setup wordpress cache generated page elements.
Comments
Post a Comment