Aug
31
2010
--

Introducing tcprstat, a TCP response time tool

Ignacio Nin and I (mostly Ignacio) have worked together to create tcprstat[1], a new tool that times TCP requests and prints out statistics on them. The output looks somewhat like vmstat or iostat, but we’ve chosen the statistics carefully so you can compute meaningful things about your TCP traffic.

What is this good for? In a nutshell, it is a lightweight way to measure response times on a server such as a database, memcached, Apache, and so on. You can use this information for historical metrics, capacity planning, troubleshooting, and monitoring to name just a few.

The tcprstat tool itself is a means of gathering raw statistics, which are suitable for storing and manipulating with other programs and scripts. By default, tcprstat works just like vmstat: it runs once, prints out a line, and exits. You’ll probably want to tell it to run forever, and continue to print out more lines. Each line contains a timestamp and information about the response time of the requests within that time period. Here “response time” means, for a given TCP connection, the time elapsed from the last inbound packet until the first outbound packet. For many simple protocols such as HTTP and MySQL, this is the moral equivalent of a query’s response time.

The statistics we chose to output by default are the count, median, average, min, max, and standard deviation of the response times, in microseconds. These are repeated for the 95th and 99th percentiles as well. Other metrics are also available. Here’s a sample:

[root@server] # tcprstat -p 3306 -n 0 -t 1
timestamp	count	max	min	avg	med	stddev	95_max	95_avg	95_std	99_max	99_avg	99_std
1276827985	1341	24556	23	149	59	767	310	91	69	1030	107	112
1276827986	1329	12098	28	134	63	461	299	91	65	667	104	93
1276827987	1180	13277	22	202	93	873	439	103	79	1523	131	169
1276827988	1441	15878	27	180	139	672	427	116	79	1045	136	128
1276827989	1432	157198	26	272	138	4165	405	115	80	1092	134	123
1276827990	1835	25198	26	183	124	734	448	115	85	1141	137	141
1276827991	1242	6949	29	129	114	301	233	98	61	686	109	84
1276827992	1480	284181	25	442	127	7432	701	128	114	4157	173	293
1276827993	1448	9339	22	161	88	425	392	104	80	1280	126	140

tcprstat uses libpcap to capture traffic. It’s a threaded application that does the minimum possible work and uses efficient data structures. Your feedback on the kernel/userland exchange overhead caused by the packet sniffing would be very appreciated — libpcap allows the user to tune this exchange, so if you have suggestions on how to improve it, that’s great.

We build statically linked binaries with the preferred version of libpcap, which means there are no dependencies. You can just run the tool. In the future, packages in the Percona repositories will provide another means for rapid installation via yum and apt.

tcprstat is beta software. Several C/C++ experts reviewed its code and gave it a thumbs-up, so many eyes have been on the code. We’ve performed tests on servers with high loads and observed minimal resource consumption. I personally have been running it for many weeks on some production servers without stopping it and have seen no problems, so I am pretty sure it has no memory leaks or other problems. Nevertheless, it’s a first prototype release, and we want much more testing. We might also change the functionality; as we build tools around it, we discover new things that might be useful. When we’re happy with it and you’re happy with it, we’ll take the Beta label away and make it GA.

The tcprstat user’s manual and links to downloads are on the Percona wiki. Commercial support and services are provided by Percona. Bug reports, feature requests, etc should go to the Launchpad project linked from the user’s manual. General discussion is welcome on the Google Group also linked from the user’s manual.

[1] Historical note: we initially called this tool rtime, but did not publicize it. However, some of you might have heard of “rtime” before. This is the same tool.


Entry posted by Baron Schwartz |
11 comments

Add to: delicious | digg | reddit | netscape | Google Bookmarks

Aug
31
2010
--

DataModeler: Simple ORM – Part 1 Models

DataModeler is an Open Source ORM I began writing at the beginning of the year. I had experience with ActiveRecord, but was dissuaded from using it too often because it was difficult to unit test (at least I felt so). Wanting to learn Test Driven Development better, I decided to create my own small ORM framework: DataModeler. In this article, I’ll go over creating a Model and the different ways you can modify one.

Aug
30
2010
--

Creating PDF Documents with Zend Framework

PHP comes with a number of options to help developers dynamically generate PDF files from within their applications. The Haru and PDF lib extensions offer a complete API for dynamic PDF generation, and there also exist a number of open-source PHP components that can be used for the same purpose. This article will introduce you to one such component, the Zend_Pdf component that ships as part of the Zend Framework, and illustrate how it can be used to perform sophisticated PDF operations from within a PHP application.

Aug
29
2010
--

A week of symfony #191 (23->29 August 2010)

Symfony2 added this week the new ControllerInterface and BaseController classes. The profiler was refactored and the web development toolbar was temporally removed (it will be included in the upcoming WebProfilerBundle). Lastly, the exception management was refactored once more and the event listeners added a new priority parameter.

Development mailing list

Development highlights

Symfony 1.X branch:

  • r30773: [1.3, 1.4] added missing processing of event

Symfony 2.X branch:

  • 1277568: [HttpFoundation] fixed Session
  • 0319838: [TwigBundle] added a flash tag
  • fe78d5f: added a way to disable the profiler
  • 9c07e46: [FrameworkBundle] added ControllerInterface. A Controller must now implement ControllerInterface. The BaseController can be used as the base class for Controllers. The Controller class adds some proxy methods and an array access to the Container.
  • 789a02d: [FrameworkBundle] and made it call Session::get
  • ec8500b: [FrameworkBundle] added support for previous exceptions in the exception pages
  • 3c42e0b: [FrameworkBundle] changed the default value of ignore_errors according to the current debug value
  • b1e7996: [DependencyInjection] moved extension loading in the freezing process (opens more possibilities in the loading order of configs)
  • a432417: [DependencyInjection] added a way to ignore errors when importing a non-existent file (useful when you want to include an optional service file)
  • bf67562: [Templating] fixed PHP renderer when using a template variable named ‘template’
  • 69f9d9c: [DoctrineMongoDBBundle] added logger and data collector for WDT
  • 0867080: [HttpFoundation] added a keys() method to *Bag classes
  • 1d7f43e: [Framework] added logs when some listeners are not called because the event has already been processed
  • 82ff790: added a priority to the event dispatcher listeners
  • 57db35b: made ExceptionManager independent of the Request
  • 92f4b92: [HttpFoundation] fixed Session serialization
  • c78528a: [FrameworkBundle] added abbrClass() and abbrMethod() helpers
  • eeb0742: [Framework] added a way to retrieve called and not-called events for a given dispatcher
  • 83a64df: added ContainerAwareInterface
  • eb66e0d: [FrameworkBundle] made exception controller embeddable
  • 72db4c7: refactored Profiler and DataCollector classes (the WDT has been removed and will be re-added in the upcoming WebProfilerBundle)
  • 0208800: refactored exception management (removed the ExceptionManager)

sfDoctrinePlugin:

  • r30774: [1.3, 1.4] changed lingering Doctrine calls to Doctrine_Core in admin generator

…and many other changes

Development digest: 51 changesets, 11 bugs reported, 28 bugs fixed, 4 enhancements suggested, 12 enhancements closed, 7 documentation defects reported, 2 documentation defects fixed, and 12 documentation edits.

Documentation

New symfony bloggers

Plugins

  • New plugins
  • Updated plugins
    • lyMediaManagerPlugin: refactored lyMediaAsset and added some unit tests, refactored lyMediaFolder, fixed wrong rounding to integer of asset file size value
    • csDoctrineActAsSortablePlugin: fixed fetchOne for large Collections
    • csDoctrineActAsGeolocatablePlugin: fixed incorrect error message in geolocatable template
    • sfAssetsLibraryPlugin: fixed some small issues in helper and routing, improved README, fixed some issues with sfWidgetFormAssetInput
    • ddOnlineStorePlugin: the fixtures files now are .sample files, is_featured field added to all products
    • sfFormExtraPlugin: added support for sfWidgetFormDateTime in sfWidgetFormJQueryDate, fixed JS function names when the widget name contains ‘-’, fixed sfWidgetFormJQueryDate doesn’t restrict values on page load, fixed sfWidgetFormJQueryDate doesn’t refresh disabled after the date was chosen from calendar, updated the autocomplete JavaScript to the latest version, added culture and theme options for sfWidgetFormReCaptcha, fixed widget for sfFormLanguage, allowed unassociated list to be left of the associated one
    • sfDatgridPlugin: clear also hidden in jquery reset search
    • sfTaskLoggerPlugin: fixed bug with logger when the task is launched in a web context: need to disconnect from dispatcher to avoid symfony to try to write in the closed file
    • sfPropel15Plugin: fixed plugin package template (remember to modify the package generated by the plugin:package task to remove the vendor/propel-generator/pear/build-pear-package.xml file, since it makes PEAR go nuts when trying to install the package)
    • ahDoctrineEasyEmbeddedRelationsPlugin: added newFormUnsetPrimaryKeys optional parameter (this allows you to embedded forms to not unset their primary keys, this is useful in composite key situations)
    • sfAdminDashPlugin: updated translations
    • diemProject:
      • fixed permission name in dmWidget/editRecords security
      • swap assets in asynchronous rendering of widget
    • apostrophePlugin:
      • added more a_include_js_calls() invocations to AJAX actions which don’t get it automatically
      • fixed aMediaCMSSlotsTools had a redundant and buggy implementation of aMediaTools::userHasUploadPrivilege()
      • the repair-tree task has been overhauled (all variants of the task now use PDO to avoid running out of memory on big page trees)
      • the repair-tree task has been overhauled (all variants of the task now use PDO to avoid running out of memory on big page trees)
      • added javascript to hide the template dropdown if your page type is not template-based
      • navigation component can now accept its active and root parameters as aPage objects
      • removed assumptions about routes
      • removed second instance of history browser from global tools
      • refactored big chunks of inline js to the apostrophe object and a_js_call
      • updated the edit categories funcitonality in the media lib sidebar to use a_js
      • the versions info array is now a flat array for JS compatibility
      • aDoctrineRoute and aRoute can no longer require an additional query to be made when using the engine-slug parameter
    • apostropheBlogPlugin:
      • backed out engineSlug in blog plugin
      • fixed count query used for blog category admin
      • changed link_to to use named route in blogCategoryAdmin
      • fixed a bug that was causing the categories listing in the page settings engine dropddown to not be alaphabetical
      • added first pass at a calendar for events
      • removed obsolete tasks that just lead to confusion
      • fixed i18n: apostropheBlogPlugin should use the apostrophe catalog just like the main plugin does
      • added some more functionality to the calendar so you can click on a day, month or year and begin browsing that way
      • fixed calendar for showSuccess and changed the getDay getMonth getYear for events to use the StartDate instead of the Pub Date
      • removed the addStylesheets and addJavascripts calls from the assets partial
      • moved the app.yml check for whether or not the calendar is enabled up into the action

New symfony powered websites

  • Billigt Grin: (Danish) a danish booking agency for upcoming stand-up comedians
  • Kvartirka.bg: (Bulgarian) find appartments for rent in Bulgaria
  • PressBulgaria.com: (Bulgarian) send press release to all medias in Bulgaria

They talked about us


Be trained by symfony experts
Oct 20 Paris – Nov 24 Paris – Dec 15 Paris

Written by in: Zend Developer |
Aug
27
2010
--

Quick Start Symfony DI (Dependency Injection) Tutorial

Dependency injection is a technique that allows for loosely coupled objects within a software application. Generally if an object requires access to the functionality of another it would be instantiated internally leading to tightly coupled systems. By implementing dependency injection we inject the required objects ready for use (sometimes also referred to inversion of control – IOC).

Aug
26
2010
--

Symfony Day 2010

After a very successful event last year, Interlutions have decided to organize the SymfonyDay event again this year. People who were there last year (126 in total from 6 different countries) can testify the conference was excellent, both the location and the schedule being very good. This year, the setup for the conference is the same, except for the location, which is now bigger and better suited than last year’s awesome location.

The schedule this year extends last year’s in terms of topics, taking the normal symfony topics and combining those with some recent topics, such as the Doctrine MongoDB ODM, Advanced symfony usage and an update on the state of Symfony2 by Fabien Potencier. It is also interesting to see that this year, there are also two guest speakers with more general PHP talks: Pierre Joye from Microsoft and Gaylord Aulke of 100 DAYS Software Projects.

As was the case last year, this year the regular conference track is again combined with a special workshop introducing symfony 1.4 development to people new or starting with symfony. During this full-day workshop, all aspects of working with symfony 1.4 to build a dynamic website will be covered so that attendees will be able to start working with symfony in building their own website as soon as they finish the workshop. New this year is the option to attend both the conference track and the workshop by offering the full-day workshop on the day after the conference.

Registration for the conference is 120 euro this year, but you can still use the early bird discount that is still available until the end of August where you get access to the conference for only 80 euro. So register now to take advantage of this discount.


Be trained by symfony experts
Oct 20 Paris – Nov 24 Paris – Dec 15 Paris

Aug
25
2010
--

Zend Framework 1.10.8 Released

The Zend Framework team announces the immediate availability of Zend Framework 1.10.8 , our eighth maintenance release in the 1.10 series. This release includes around 22 bug fixes.

A special reminder to those users of Zend_Service_Twitter , please ensure you upgrade to 1.10.6, 1.10.7, or 1.10.8 ASAP. These releases introduce a change in the Zend_Service_Twitter API that enforces the use of OAuth by default when using methods that require authentication. The change was introduced to help prepare Zend Framework users for the Twitter OAuthcalypse scheduled in 6 days from now on August 31, 2010 . (If you cannot upgrade, there are other ways to integrate Zend_Oauth with Zend_Service_Twitter .)

Aug
24
2010
--

NP-Gravatar

Zend Framework extension, which provides classes for using and implementing Gravatar’s services and features. It consists of HTTP client for performing Gravatar Profile Requests, client for Gravatar XML – RPC API and view helper for rendering Gravatar image URL s.

Aug
23
2010
--

InnoDB memory allocation, ulimit, and OpenSUSE

I recently encountered an interesting case. A customer reported that mysqld crashed on start on OpenSUSE 11.2 kernel 2.6.31.12-0.2-desktop x86_64   with 96 GB RAM when the innodb_buffer_pool_size was set to anything more than 62 GB. I decided to try it with 76 GB. The error message was an assert due to a failed malloc() in ut_malloc_low() in ut/ut0mem.c inside InnoDB source code. InnoDB wraps the majority of its memory allocations in ut_malloc_low(), so to get an idea of the pattern of requested allocations I added a debugging fprintf() to tell me how much was being allocated and whether it was successful.

I discovered something interesting. I expected the allocation to fail on the 76 GB of the buffer pool, due to some weird memory mapping issue and a continuous block of 76 GB not being available. However, that is not what happened. 76 GB buffer was allocated successfully. What was failing is the allocation of 3.37GB after that. What in the world could InnoDB need that was 3.37 GB? There was nothing in the settings that asked for anything close to 3 GB explicitly.

Source code is the ultimate documentation, and I took advantage of that. My good friend GDB guided me to buf_pool_init() in buf/buf0buf.c. There I found the following:

buf_pool->frame_mem = os_mem_alloc_large(
UNIV_PAGE_SIZE * (n_frames + 1),
TRUE, FALSE);

That was the buffer pool itself, the 76 GB of it. And now the buffer pool’s friend:

buf_pool->blocks = ut_malloc(sizeof(buf_block_t) * max_size);

3.6 GB of it!

From the comments in the code (InnoDB code actually has very good comments), max_size is the maximum number of buffer pool pages (16K each), n_frames which is the same thing unless AWE is used, but it was not used, so I did not worry about it.

What shall we call that friend? It is used for storing some meta information about buffer pool pages. The most natural name I could come up with from reading the source code is the blocks array.

Thus we can see that we are allocating another chunk that is in proportion to the setting of innodb_buffer_pool_size for the blocks array. The exact proportions will probably vary from version to version, but roughly about 1 G for every 25 G of the buffer pool. This can become significant in the proper innodb_buffer_pool_size estimations when the system has a lot of RAM and you want to have the largest possible innodb_buffer_pool_size. Do not forget to give the blocks array some room!

While this was an interesting investigation, it nevertheless did not explain why there was not enough room for a 76 GB buffer pool. Even with the extra 3.37 GB allocation, there was still some free memory. Or was there? Maybe some hidden monster was eating it up? I quickly wrote this hack to prove or disprove the monster’s presence.

I verified that I could allocate and initialize two chunks of 40 GB from two separate processes, but not 80 GB from one. In fact, 80GB allocation failed right in malloc(), did not even get to initialization. I tested it with allocating 70 GB concurrently in each process so as to overrun physical memory + swap. Both allocations were successful, one initialized successfully, the other was killed by the OOM kill during initialization.

This smelled like a low ulimit, and sure enough it was. ulimit -m ulimited; ulimit -v unlimited did the magic, and mysqld successfully started with an 80 GB buffer pool. Apparenly OpenSUSE defaults are set in proportion to physical memory to keep the memory-hungry applications from taking the system down. On this particular system (96 GB physical memory, 2 GB swap it decided to set the virtual memory ulimit (-v) to 77.27 GB, and the physical memory (-m) to 80.40 GB).


Entry posted by Sasha Pachev |
7 comments

Add to: delicious | digg | reddit | netscape | Google Bookmarks

Written by in: MySQL,Zend Developer |
Aug
23
2010
--

Prison for water..

Punishment for early escape: You have to help destroy Los Angeles

Conditions for release on time: you have to help destroy Los Angeles

http://en.wikipedia.org/wiki/File:Lake_Hollywood_Reservoir_by_clinton_steeds.jpg



Powered by WordPress | Theme: Aeros 2.0 by TheBuckmaker.com