互联网女皇2013年趋势报告:个人数据革命

May 29, 2013 Leave a comment

美国KPCB风险投资公司的著名互联网分析师玛丽・米克尔(Mary Meeker)素有“互联网女皇”之称,她每年发布的《互联网趋势报告》在业界极具影响力。本周三,米克尔在AllThingsD D11大会上发布了她最新的报告。以下是报告主要内容:

    

from cnBeta.COM http://www.cnbeta.com/articles/239178.htm

Categories: GR Tags:

Apple Will No Longer Approve Apps Using Unique Device Identifier (UDID) Beginning May 1

March 21, 2013 Leave a comment

NewImageApple has informed app developers that it will no longer allow apps to use the unique device identifier or UDID after May 1, according to a post on Apple’s developer website.

Instead, Apple requests developers use the new ‘Vendor or Advertising identifiers’ that were introduced in iOS 6.

Using Identifiers in Your Apps
March 21, 2013

Starting May 1, the App Store will no longer accept new apps or app updates that access UDIDs. Please update your apps and servers to associate users with the Vendor or Advertising identifiers introduced in iOS 6. You can find more details in the UIDevice Class Reference.

Apple announced in 2011 that it would be phasing out developer access to UDID’s, and instead create a non-identifying marker for advertisers to use. A year ago, it was reported that Apple began quietly rejecting apps for the use of the UDID, but this public announcement suggests Apple has gotten more serious about shutting down use of the identifier.

Apple had been under increased pressure to change how the UDID works due to the privacy implications of a developer knowing which particular iOS device is being used to access their app. Apple and several app developers were sued over the use of the UDID to track users across different apps. While the UDID doesn’t specifically identify a user, the sharing of UDIDs across ad networks and apps can help piece together a valuable picture of activity and interests of the user of a specific device. Apple seems to be requiring apps to generate their own unique identifiers for each installation to avoid this ability to share such information across apps.

Recent Mac and iOS Blog Stories
Redesigned ‘Speedtest.net’ App Released, Improved Server Selection and Sharing
A Look at American Airlines’ iPad Electronic Flight Bag
Apple Tops J.D. Power Smartphone Satisfaction Rankings By Significant Margin
Black Pixel to Revive ‘NetNewsWire’ With Cross-Device Syncing
Cleveland Museum of Art Uses iPads for Visitor-Personalized Tours
Pixelmator Crashing Issue Fixed in OS X 10.8.3
MagSafe Adapter Key Ring Connects MagSafe Converter to Keys
GarageBand for iOS Updated With Audiobus Support and Other Enhancements

from MacRumors: Mac News and Rumors – Front Page http://www.macrumors.com/2013/03/21/apple-will-no-longer-approve-apps-using-unique-device-identifier-udid-beginning-may-1/

Categories: GR Tags:

Twemproxy – Twitter 开源的 Redis proxy

March 18, 2013 Leave a comment

在去年的QCon London2012 大会上,Twitter 发表了题为 《Timelines @ Twitter》的演讲,里面提到以Redis作为其timeline的主要存储,目前目测全球范围内,Twitter可能是Redis的最大用户了(或者是新浪微博?)。

而今天我们要说的这个Twemproxy,是 Twitter 开源出来的 Redis 和 Memcached 代理。

功能介绍

我们知道,无论是 Memcached 还是当前的 Redis,其本身都不具备分布式集群特性,当我们有大量 Redis 或 Memcached 的时候,通常只能通过客户端的一些数据分配算法(比如一致性哈希),来实现集群存储的特性。

Twemproxy 通过引入一个代理层,可以将其后端的多台 Redis 或 Memcached 实例进行统一管理与分配,使应用程序只需要在 Twemproxy 上进行操作,而不用关心后面具体有多少个真实的 Redis 或 Memcached 存储。

在 Redis 的 Cluster 方案还没有正式推出之前,通过 Proxy 的方式来实现存储集群可能是最好的选择了。更何况 Twemproxy 是通过 Twitter 自身得到了充分检验的产品。

性能

根据 Redis 作者的测试结果,在大多数情况下,Twemproxy 的性能相当不错,直接操作 Redis 相比,最多只有20%的性能损失。这对于它带来的好处来说真的是微不足道了。唯一可能还有待改进的是其 MGET 操作的效率,其性能只有直接操作 Redis 的 50%。

安装与配置

Twemproxy 的安装有点小麻烦,主要命令如下:

apt-get install automake
apt-get install libtool
git clone git://github.com/twitter/twemproxy.git
cd twemproxy
autoreconf -fvi
./configure --enable-debug=log
make
src/nutcracker -h

通过上面的命令就算安装好了,然后是具体的配置,下面是一个典型的配置

redis1:
  listen: 0.0.0.0:9999 #使用哪个端口启动Twemproxy
  redis: true #是否是Redis的proxy
  hash: fnv1a_64 #指定具体的hash函数
  distribution: ketama #具体的hash算法
  auto_eject_hosts: true #是否在结点无法响应的时候临时摘除结点
  timeout: 400 #超时时间(毫秒)
  server_retry_timeout: 2000 #重试的时间(毫秒)
  server_failure_limit: 1 #结点故障多少次就算摘除掉
  servers: #下面表示所有的Redis节点(IP:端口号:权重)
   - 127.0.0.1:6379:1
   - 127.0.0.1:6380:1
   - 127.0.0.1:6381:1
   - 127.0.0.1:6382:1

redis2:
  listen: 0.0.0.0:10000
  redis: true
  hash: fnv1a_64
  distribution: ketama
  auto_eject_hosts: false
  timeout: 400
  servers:
   - 127.0.0.1:6379:1
   - 127.0.0.1:6380:1
   - 127.0.0.1:6381:1
   - 127.

from NoSQLFan http://item.feedsky.com/~feedsky/nosqlfan/~8149226/710154282/6253001/1/item.html

Categories: GR Tags:

Ceylon M5 with Tuples, Verbatim Strings, Spread Operator, Late Annotation

March 17, 2013 Leave a comment

RedHat has released Ceylon M5 programming language with several new features such as Tuples, Verbatim Strings, Spread Operator, Late Annotation and reified generics including a new module, package, functions in addition to several key syntax modifications. By Anand Narayanaswamy

from InfoQ Personalized Feed for rongying zhou http://www.infoq.com/news/2013/03/ceylon-m5

Categories: GR Tags:

A Beginner’s Guide to HTML & CSS

March 17, 2013 Leave a comment

from A Beginner's Guide to HTML & CSS http://learn.shayhowe.com/html-css/

Categories: GR Tags:

This week’s headlines from across Inside Network

February 24, 2013 Leave a comment

A roundup of all the news Inside Network brought you between Feb. 18 and Feb. 22.

Inside Mobile Apps

Tracking the convergence of mobile apps, social platforms and virtual goods.

Tuesday, Feb. 19

Wednesday, Feb. 20

Thursday, Feb. 21

Friday, Feb. 22

Inside Social Games

Covering all the latest developments at the intersection of games and social platforms. Tuesday, Feb. 19

Wednesday, Feb. 20

Thursday, Feb. 21

Friday, Feb. 22

Inside Facebook

Tracking Facebook and the Facebook platform for developers and marketers.

Monday, Feb. 18
Tuesday, Feb. 19

Wednesday, Feb. 20

Thursday, Feb. 21

Friday, Feb. 22

Inside Social Commerce

Tracking the convergence of social media and commerce.

from Inside Facebook http://www.insidefacebook.com/2013/02/24/this-weeks-headlines-from-across-inside-network-42/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+InsideFacebook+%28Inside+Facebook%29

Categories: GR Tags:

PECL/mysqlnd_ms 1.5 + PHP 5.5.0 + MySQL 5.6 = better load balancing

February 24, 2013 Leave a comment

PECL/mysqlnd_ms is a client-side load balancer for PHP that supports any MySQL cluster. It does read-write splitting, failover, introduces a quality of service concept, supports partitioning and, of course, load balancing. New mysqli API (begin, *savepoint) calls in PHP 5.5.0 help to improve transaction awareness. New read only in MySQL 5.6 promise major performance gains (think 2x) and an option to reduce the load on a MySQL Replication master. Read how the features go together in PECL/mysqlnd_ms 1.5.

Load balancing – transaction aware?

A load balancer must not switch connections in the middle of a transaction. A load balancer must send all queries to the server a transaction has been started on until the transaction ends. Unfortunately, it is very hard to develop a transparent load balancer for MySQL. In general there are four approaches:

  • forget about transparency and require applications to hint the load balancer about transaction boundaries (buuuh!)
  • have the MySQL server announce transactions to clients on the wirte protocol (buggy :-()
  • monitor SQL queries controlling transactions
  • monitor API calls controlling transactions

PECL/mysqlnd_ms supports the basic hinting and the API monitoring approach. Using SQL hints to control load balancing during transactions is possible but very uncomfortable.

$mysqli = new mysqli(...);
$mysqli->query("BEGIN");
/* stop load balancing, force use of last server */
$mysqli->query(sprintf("/*%s*/INSERT INTO test(id) VALUES (1)", MYSQLND_MS_LAST_USED_SWITCH));
sprintf("/*%s*/COMMIT", MYSQLND_MS_LAST_USED_SWITCH));

API monitoring is a step forward. If transaction stickiness has been configured, PECL/mysqlnd_ms stops load balancing once autocommit is turned off. Given you set trx_stickiness=master, the load balancer will run all transactions on the master.

$mysqli->autocommit(false);
/* autocommit is off, must not switch connections if transaction_stickiness is set */
$mysqli->query("INSERT INTO test(id) VALUES (1)");

$pdo->setAttribute(PDO::ATTR_AUTOCOMMIT, false);
/* if trx_stickiness is set, no connection switch allowed */
$stmt = $pdo->prepare("SELECT @myrole AS _role");
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);

Internally, PECL/mysqlnd_ms hooks the autocommit() C API function of mysqlnd. PDO_MySQL and mysqli call it and thus, PECL/mysqlnd_ms recognizes the change.

Any PHP MySQL application
|
$pdo->setAttribute(PDO::ATTR_AUTOCOMMIT, false); $mysqli->autocommit(false);
mysqlnd autocommit()
PECL/mysqlnd_ms autocommit():
transaction stickiness set and in transaction?
|  
MySQL Master MySQL Slave

However, remember that if you used SQL to control the autocommit mode, PECL/mysqlnd_ms would not recognize the change and transaction stickiness would not work.

MySQL C API vs. PHP API

As a PHP user, you may be surprised to hear that autocommit() is the only call monitored in PECL/mysqlnd_ms 1.4. That’s because its pretty much all the MySQL C API had to offer and thus, all the plugin could hook and use to detect transaction boundaries. For example, PECL/mysqlnd_ms 1.4 cannot be made aware of a call to PDO::beginTransaction() because PDO::beginTransaction() does not map to any MySQL C API call that the plugin could monitor.

A close look unveils that SQL offers way more options to control transactions than the MySQL C API.

SQL MySQL C API PHP 5.4 MySQL APIs
SET autocommit mysql_autocommit() mysqli_autocommit(), PDO::ATTR_AUTOCOMMIT
START TRANSACTION n/a PDO::beginTransaction()
START TRANSACTION transaction_characteristic (e.g. READ ONLY) n/a n/a
COMMIT mysql_commit() mysqli_commit(), PDO::commit()
COMMIT [WORK] [AND [NO] CHAIN] [[NO] RELEASE] n/a n/a
ROLLBACK mysql_rollback() mysqli_rollback(), PDO::rollBack()
ROLLBACK [WORK] [AND [NO] CHAIN] [[NO] RELEASE] n/a n/a

The feature gap between SQL and PHP (mysqli) API is closed in PHP 5.5. The mysqlnd C library has been extended to offer C calls for all SQL features. Those C calls can be monitored by PECL/mysqlnd_ms 1.5. And, those calls are exported to the mysqli API. The transaction aware load balancing of PECL/mysqlnd_ms 1.5 is no longer limited to autocommit() but covers all of the below mysqli_*-functions.

SQL PHP 5.5 MySQL APIs
SET autocommit mysqli_autocommit(), PDO::ATTR_AUTOCOMMIT
START TRANSACTION mysqli_begin_transaction(), PDO::beginTransaction()
START TRANSACTION transaction_characteristic (e.g. READ ONLY) mysqli_begin_transaction([option [, name]])
COMMIT mysqli_commit(), PDO::commit()
COMMIT [WORK] [AND [NO] CHAIN] [[NO] RELEASE] mysqli_commit([option])
ROLLBACK mysqli_rollback(), PDO::rollBack()
ROLLBACK [WORK] [AND [NO] CHAIN] [[NO] RELEASE] mysqli_rollback([option])

PDO_MySQL has not been modified yet to use the new mysqlnd API calls. Work in progress… even the mysqli API additions have not been documented yet.

mysqli constant Comment
MYSQLI_TRANS_START_WITH_CONSISTENT_SNAPSHOT, MYSQLI_TRANS_START_READ_WRITE, MYSQLI_TRANS_START_READ_ONLY For mysqli_begin_transaction(). See SQL.
MYSQLI_TRANS_COR_AND_CHAIN, MYSQLI_TRANS_COR_AND_NO_CHAIN, MYSQLI_TRANS_COR_RELEASE, MYSQLI_TRANS_COR_NO_RELEASE Use with mysqli_commit(), mysqli_rollback(). See SQL.

Better load balancing in PECL/mysqlnd_ms 1.5

MySQL 5.6 introduces read only transactions. If you tell InnoDB in advance that a transaction will perform read operations only, it can be executed faster than a transaction that may perform a write. Early MySQL 5.6 Release Candidate benchmarks hinted that read only transactions could run twice as fast as normal transactions. You can use the SQL statement
START TRANSACTION READ ONLY to begin a read only transaction, or you use the new mysqli API features of PHP 5.5.0.

$mysqli->begin_transaction(MYSQLI_TRANS_START_READ_ONLY);
$mysqli->query(...);
$mysqli->query(...);
$mysqli->commit();

Using the API has the advantage that PECL/mysqlnd_ms 1.5 can do transaction aware load balancing: the plugin picks a server to run the transaction and continues using it until the transaction ends. If MYSQLI_TRANS_START_READ_ONLY is set, the plugin may try to run the transaction on a slave in order to reduce the load on the master. Whether the transaction will end up on a slave depends on a number of additional factors.

trx_stickiness setting mysqli call version requirements
PECL/mysqlnd_ms load balancing
not set $mysqli->begin_transaction()  
Ignored! Load balancer may switch connections at any time. Not transaction safe!
master $mysqli->autocommit(), PDO::ATTR_AUTOCOMMIT PHP 5.4, PECL/mysqlnd_ms 1.2
If autocommit is turned off, choose master and used it until autocommit is enabled again. Once autocommit is enabled, switching servers may happen at any time.
master $mysqli->begin_transaction() PHP 5.5, PECL/mysqlnd_ms 1.5
Choose a master: if failover is enabled, search a master until you find one based on failover rules. Once a master has been found stop load balancing, stop failover. Use master until the end of the transaction, monitor mysqli_commit(), mysqli_rollback() C API counterparts to learn about the end of the transaction.
on $mysqli->begin_transaction(MYSQLI_TRANS_START_READ_ONLY) PHP 5.5, PECL/mysqlnd_ms 1.5
Try to use a slave to run the transaction on. Try to use slave only if master-on-write and the current quality of service setting allows it. For example, if strong consistency has been requested, slaves will not be considered. If no slaves are configured or all slaves have failed, try using a master (see above).

Beside all the improvements, it would be so much easier for clients to do proper transaction aware load balancing if the server would announce the begin and end of a transaction on the wire protocol…

Happy hacking!

@Ulf_Wendel Follow me on Twitter

The post PECL/mysqlnd_ms 1.5 + PHP 5.5.0 + MySQL 5.6 = better load balancing appeared first on Ulf Wendel.

PlanetMySQL Voting:
Vote UP /
Vote DOWN

from Planet MySQL http://blog.ulf-wendel.de/2013/peclmysqlnd_ms-1-5-php-5-5-0-mysql-5-6-better-load-balancing/

Categories: GR Tags: