PHP - Php Websocket Usage / Memory
For example, take a look at this: https://code.google....p/phpwebsocket/
When I run the server, it works fine and I am using the server for my Inventory system on my game. When users drag and drop items in their inventory to change position, it sends the data to the html 5 websocket server, and updates the positions accordingly/etc. And I will use it for a bunch of other stuff later.
My question is: What kind of VPS would I be looking for in terms of ram/cpu power to keep a websocket server like this up 24/7? Is it more memory intensive than socket/io/nodejs? Or what? How can I test these things? Looking at cmd.exe or php.exe in my task manager when having it run on my local windows machine isn't really a good way to test performance, or to estimate how much ram or VPS/CPU power of a server I'll need before launch. I can get a idea, but I don't think it's going to be close to reality. That's why I'm asking you guys here if you would know. Thanks
Edited by Monkuar, 17 January 2015 - 12:24 AM. Similar Tutorialsthe difference between memory usage and bandwidth usage? I did a test with 500 rows in table, got 2.36mb memory usage, and then once without 500 rows in table, i got 2.34 (IN MBS) memory usage, can that translate into bandwidth usage? somone told me that bandwidth usage != memory usage, how so? it does effect it some doesn't it ? Hello, So I am trying to reduce my memory footprint to the lowest possible value without sacrificing functionality. I noticed that if I write a comment that is 2kb long, it costs me 2kb more memory to run the script. How can I get PHP to free the memory taken up by comments? It seems like it would be a real pain in the butt to have to run php -w on all my source files each time I update my server. Any ideas? Thanks. David I have some simple test code: Code: [Select] echo memory_get_usage(true); echo("\n" . '<br />' . "\n"); echo memory_get_usage(false); echo("\n" . '<br />' . "\n"); echo memory_get_peak_usage(); that prints out the three types of memory usage in bytes for my basic admin page. All three values are around 2.25 MB in bytes. What's best practice for PHP memory usage? Is 2.25MB far too much for a single user's visit? Do these PHP memory values include images in the page? I've been doing some benchmarking for memory usage for a very resource-sensitive project I'm doing (that I probably shouldn't be using PHP for, but oh well). I came across something peculiar, and I'm trying to figure out why I get results as I do. Here is my test file: <?php $string_parts = 4; $max = 10000; $arr = array(); $i = 0; $start = memory_get_usage(); for(;$i<$max;$i++){ $arr[] = array_pad(array(), 4, "A"); } $end = memory_get_usage(); printf("%d iterations, %d bytes in array\n", $max, $end-$start); $arr2 = array(); $i = 0; $start2 = memory_get_usage(); for(;$i<$max;$i++){ $arr2[] = array("A", "A", "A", "A"); } $end2 = memory_get_usage(); printf("%d iterations, %d bytes in array (%.2f%%)\n", $max, $end2-$start2, ($end2-$start2)/($end-$start)*100); ?> Output on my system: Code: [Select] 10000 iterations, 4145696 bytes in array 10000 iterations, 5585744 bytes in array (134.74%) A 35% memory gain for two of the same exact arrays seems really weird. Any information as to why, or perhaps any useful functions or resources would be appreciated.
I'm currently trying to building a websocket widget, using node package manager(NPM),WAMPserver and electronjs. I bought a script not so long back and I am trying to install it on my Linux hosting cPanel with GoDaddy.
I have followed the installation instructions (below) provided by the script author but I am having no luck.
1. Modify server/server.php Line: 282
$master = new ChatBot(“(author's domain)”, 10000); Hi, My hosting disabled my account because my site used too many system resources (CPU). There is no way for me to know how much CPU my site is using since i am not a psychic or god so no clue how they expect me to monitor this or fix this (the site has been running just fine for 2 years with the same code). Is there any code that can tell me how much CPU my site is using on the server? Thanks in advance, Jay Hi guys, Yet another rookie question, trying to implement this: I have a function: <?php //MyHelper.php function getnext( $name ) { $conn = DB::table('counter')->where('name', $name )->first(); $result = $conn->findAndModify( ['name' => $name], ['_id' => ['seq' => 1]], ['seq' => true], ['new' => true, 'upsert' => true] ); return $result['seq']; } ?> And I am calling it so: $db_array = getnext(array('name' => 'role_id')); print_r( $db_array); Results in call to a member function on NULL, not sure where I'm going wrong! It is making a connection and the counter table has a 'role_id' in it. Can anyone tell me where I'm going wrong? I have searched a lot but no information about this aspect. I wonder how much heavy is the process of getting parts of a webpage by preg_match? But my question is that which of these options are in favor of lighter CPU process: 1. getting each item between specified tags by a preg_match or 2. First getting the content between <body>, then processing by php tools such as preg_match (again), explode, etc. Thanks for considering this unusual question So I'm debating whats the best method. I'm aware that catch/blocks should be used in exceptional cases but what if it saves me from having 4 nested if/else conditions? The following is code for an xbox registration site Code: [Select] try { // check code is valid $c1 = $this->input->post('code1',true); $c2 = $this->input->post('code2',true); $c3 = $this->input->post('code3',true); $gt = $this->input->post('gamertag',true); $pass = $this->input->post('password',true); if( $c1 == '' || $c2 == '' || $c3 == '') { throw new FormError("Authorization code invalid."); } // check db for code validation $q = $this->db->query("select * from `codes` where `activated` = 0 and `code` = ".$c1.$c2.$c3." limit 0,1"); if($q->num_rows() != 1) { throw new FormError("Authorization code invalid."); } $r = $q->row_array(); $email = $r["recipient_email"]; $codeGt = $r["gamertag"]; // check valid gamertag $q = $this->db->query("select * from `users` where `gamertag` = '".$gt."'"); if($q->num_rows() > 0) { throw new FormError("Gamertag already exists."); } // validate gamertag /w inputted gamertag if(strtolower($codeGt) != strtolower($gt)) { throw new FormError("Gamertag Invalid"); } $this->_createAccount($email,$pass,$gt); // show register-thanks screen $this->load->view("register-thanks",$data); $success = true; } catch (Exception $e) { $data['error'] = $e->getMessage(); } I was wondering how to resize DIVs based upon their usage. I have some vague ideas of how to do it, but not sure. Basically, the more a user clicks a DIV, the large it becomes relative to all other DIVs (no DIVs ever disappear!) Any ideas? This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=320813.0 i am new with web socket
and in same time
I try to make server and client communication for soccer manager application, and for this purpose, i need to create closed "chat rooms" or "games" where two users can watch (read game event) and menage (create) game event (make substitution, formation ... or if you want, to send message to server, that they make changes in formation)
this game (room) mast bi secret, and only this two player can use this game for "read" and "write" events in game
for example: Game no: 200001 between user A and user B in 14.05.
when User A, and User B click on game no. 200001 they can read and write game event.
PS: for now, i create basic chat aplication with PHP, jQuery and webSocket and in this app, all user see wath all other user do (public chat) and i want to make secret chat for specific user (already automate subscribed from server) All work with no problem (i work on this example http://www.sanwebe.c...ket-php-socket)
How i can create chat room(s) and subscribe user to specific chat room?
Thanks
Edited by laponac84, 30 November 2014 - 09:09 AM. This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=319964.0 This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=346818.0 Hey guys, I can't wrap my head around how to make this work right... I have three tables: Code: [Select] CREATE TABLE `games` ( `g_id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(150) DEFAULT NULL, PRIMARY KEY (`g_id`)); CREATE TABLE IF NOT EXISTS `game_player` ( `r_id` int(11) NOT NULL AUTO_INCREMENT, `p_id` int(11) DEFAULT NULL, `g_id` int(11) DEFAULT NULL, `bool` int(1) NOT NULL DEFAULT '0', PRIMARY KEY (`r_id`)); CREATE TABLE IF NOT EXISTS `players` ( `p_id` int(11) NOT NULL AUTO_INCREMENT, `playerid` varchar(150) NOT NULL, PRIMARY KEY (`p_id`), UNIQUE KEY `playerid` (`playerid`)); The players table is my list of users, and they're tied to the list of games via the game_player table. So here's my issue... I'm trying to show the full list of games, and then check mark each record where the player does play it. This is what I have so far - it shows all the games, but it's not checking the boxes. Code: [Select] $result = mysql_query("SELECT * FROM games") or die(mysql_error()); while($row = mysql_fetch_array($result)) { $newquery = "SELECT * FROM game_player, players WHERE game_player.p_id = players.p_id AND game_player.g_id = ".$row['g_id']. " AND players.playerid = {$userid}"; $query = mysql_query($newquery) or die(mysql_error()); if($query['bool'] == 1) { $set_checked = " CHECKED"; } else{ $set_checked = ""; } echo "<input type=\"checkbox\" name=\"box1\" value=\"".$query['g_id']."\"" . $set_checked . "/>".$row['name']."<br />\n"; } hello and good day
first of all:; i hope youre all right and everything goes well at your site;: Worpress-Plugin API - giving back the meta-data according the usage of different filters
I'm currently working on a parser to make a small preview on the newest plugins in wordpress. at the moment i think i work from a URL given out of the range of these: https://de.wordpress.org/plugins/browse/popular/ - let us say the first 30 to 40 URL-pages.
What i subsequently want to filter out after the fetch is - those plugins that have the newest timestamp Version: 1.9.5.12 installations: 10,000+ WordPress Version: 5.0 or higher Tested up to: 5.4 PHP Version: 5.6 or higher Tags 3 Tags: database member sign-up form volunteer Last updated: 19 hours ago plugin-ratings
Supported arguments per action +--------------------+---------------+--------------------+----------+----------------+ | | | | | | +--------------------+---------------+--------------------+----------+----------------+ | Argument Name | query_plugins | plugin_information | hot_tags | hot_categories | | $slug | No | Yes | No | No | | $per_page | Yes | No | No | No | | $page | Yes | No | No | No | | $number | No | No | Yes | Yes | | $search | Yes | No | No | No | | $tag | Yes | No | No | No | | $author | Yes | No | No | No | | $user | Yes | No | No | No | | $browse | Yes | No | No | No | | $locale | Yes | Yes | No | No | | $installed_plugins | Yes | No | No | No | | $is_ssl | Yes | Yes | No | No | | $fields | Yes | Yes | No | No | +--------------------+---------------+--------------------+----------+----------------+
regards dil_Bert
cf: https://developer.wordpress.org/reference/functions/plugins_api/ $fields = array( 'active_installs' => true, // rounded int 'added' => true, // date 'author' => true, // a href html 'author_block_count' => true, // int 'author_block_rating' => true, // int 'author_profile' => true, // url 'banners' => true, // array( [low], [high] ) 'compatibility' => false, // empty array? 'contributors' => true, // array( array( [profile], [avatar], [display_name] ) 'description' => false, // string 'donate_link' => true, // url 'download_link' => true, // url 'downloaded' => false, // int // 'group' => false, // n/a 'homepage' => true, // url 'icons' => false, // array( [1x] url, [2x] url ) 'last_updated' => true, // datetime 'name' => true, // string 'num_ratings' => true, // int 'rating' => true, // int 'ratings' => true, // array( [5..0] ) 'requires' => true, // version string 'requires_php' => true, // version string // 'reviews' => false, // n/a, part of 'sections' 'screenshots' => true, // array( array( [src], ) ) 'sections' => true, // array( [description], [installation], [changelog], [reviews], ...) 'short_description' => false, // string 'slug' => true, // string 'support_threads' => true, // int 'support_threads_resolved' => true, // int 'tags' => true, // array( ) 'tested' => true, // version string 'version' => true, // version string 'versions' => true, // array( [version] url ) );
what do you say-!? I am in the midst of developing a web application and despite having a decent amount of experience in web development, I never really stopped and gave a ton of thought to memory when it comes to my php scripts. However, with this project I am using zend framework and it is a decent memory hog. So I have some questions... I am monitoring my memory use for a typical call to my site and it appears as though its somewhere around 20MB. This seems like a ton and I am actively looking for ways to decrease it. One thing I noticed is that when I call zend's date class for the first time, my memory usage shoots up 3MB. However it is pretty much untouched for other instances of this class. So if I do Code: [Select] echo(memory_get_usage()); echo('<br />'); $this->last_login=Zend_Date::now(); echo(memory_get_usage()); echo('<br />'); $this->last_active=Zend_Date::now(); echo(memory_get_usage()); echo('<br />'); The result is Quote 9136448 12812408 12814496 So the jump is with that first call. My question is, if two users are accessing the site at the same time, will they both experience that 3MB memory use? Or will the server have that class in memory so it only uses 3MB once? Basically, if a call to the site uses 20MB of memory, will it be 20MB * the number of users. Or will the server have a lot of the information loaded into memory to subsequent calls so multiple users would use up far less memory then the initial? I would assume the latter is the case based on the fact that reusing zend_date doesn't incur a 3MB hit every time. But without being admin of my server and hvaing tons of folks to test at once, its hard to tell. Just how big can i make this ? Im sure it depends on the server hardware and if thats the case then how does one fidn out how big I can make this. I want to max it out. -SB I have osTicket installed on a Centos 5 Os with php5.3.3
I upgraded the osTicket from v1.9.1 to 1.9.4
I now get the following mail when I create a ticket by mailing in the support ticket
This is the mail system at host mail.mydomain.com.
I'm sorry to have to inform you that your message could not be delivered to one or more recipients. It's attached below.
For further assistance, please send mail to <postmaster>
If you do so, please include this problem report. You can delete your own text from the attached returned message.
The mail system
<support@mydomain.com>: Command died with status 255: "/usr/bin/php -q
/var/www/html/support/api/pipe.php". Command output: PHP Fatal error:
Allowed memory size of 268435456 bytes exhausted (tried to allocate 76
bytes) in /var/www/html/support/include/class.osticket.php on line 261 PHP
Warning: Unknown: Error occured while closing statement in Unknown on line
0
The osticket guys have pointed out to me that this is a php error, but I never made any changes to the php config
When I increase the memory in php.ini to 512Mb or even 1024Mb the error persists.
Anyone have any ideas of whether the memory is set/can be set somewhere else or overriding what is in php.ini ?
|